Re: [dev] nscript - a little stack-based scripting language interpretter I wrote

From: pancake <pancake_AT_youterm.com>
Date: Wed, 25 Aug 2010 23:40:24 +0200

Yo

On Aug 26, 2010, at 12:08 AM, Nikhilesh S <s.nikhilesh_AT_gmail.com> wrote:

> On Wed, 25 Aug 2010, pancake wrote:
>
>> * Remove 'code' in nstest.c and put it as a testcase t/test
>
> nstest.c is gone, there's now ns.c, a standard-input-interpreter. The
> tests are now in the directory test/. You can now just run './ns <
> test/fact.ns' for example.
>
Good!

>> * floating point support (append '.' or 'f' to each basic math op
>> +. , -. ...)
>
> Maybe I should add a new 'float' type, and then the +, - etc.
> operators
> will promote int to float when they are parameters to the same
> operator?
>
Yeah, but I'll probably use double. To avoid some precision issues

>> * function to execute commands in shell and get output in stack
>> * Onechar and line input reading
>
> Line input reading is good, command execution is good, I'll add it.
>

Check Sal src, I already did a similar task whn defining a basic API
for the language

Would be great if we can extend it in C doing something like ( 'swk'
loadlib) .. Maybe not as in shared libs, but for namespaces can be good.

> Should I add a new 'char' type for onechar reading?
>
I vote for 1char string, no new type. And u can reuse the rest of
operators

>> * format string implementation (maybe)
>
>> * type check functions (how can I know the type of the last element
>> in the stack?
>
> Nice idea, but I'm wondering how should the type should be
> represented? Integer constants (0 for int, 1 for bool, ...),
> strings, characters?

Why not return an int with the enum value?
>
>> * I will probably swap the order of the conditional clauses: (what
>> do you think about it)
>> 3 3 == { 'Is equal duppy\n' print } if
>> -->
>> { 'Is equal duppy\n' print } 3 3 == if
>
> Hmm, personally I prefer the 'condition first' order... Why do you
> like
> the 'condition later' order?
>
My way is more logical fr a stack based vm. Just flip your mind. :)
>
Received on Wed Aug 25 2010 - 23:40:24 CEST

This archive was generated by hypermail 2.2.0 : Wed Aug 25 2010 - 23:48:02 CEST