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

From: yy <yiyu.jgl_AT_gmail.com>
Date: Wed, 25 Aug 2010 21:51:13 +0200

2010/8/25 Kris Maglione <maglione.k_AT_gmail.com>:
> On Wed, Aug 25, 2010 at 01:54:37PM +0200, pancake wrote:
>> * I would probably prefer '"' quote char for strings.
>
> I think this is irrelevant. It's down to the preference of the language
> designer. Most scripting languages support single quoted strings, some
> (python) favor them, and some (rc) implement them exclusively. My personal
> preference is for single-quoted strings to ignore escape sequences, and to
> escape single quotes by doubling them, and for double-quoted strings to
> process escapes and possibly do simple interpolation.

The fact that shells normally use single quotes for literal text
strings is an argument in favor of double quotes in a scripting
language. It makes much easier to embed it in shell scripts (see awk,
for example).

>> * 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
>
> I agree. It's cleaner, and it's closer to forth, which is always good.

Conditionals are not really a part of Forth (actually, it is
considered good style to avoid them), neither are code blocks. The
most common implementation would use IF ... THEN, in the example:

    3 3 == IF 'Is equal duppy\n' print THEN

I find this construction really confusing. FWIW, I prefer laforth style.

However, one idea that has been around my head for some time now is a
language with different stacks for each type. Then, you would have a
blocks stack and a booleans stack. If would take the top value from
the bool stack and, if true, would execute the top value of the block
stack. This way, it would not matter if you use 3 3 == { 'Is equal
duppy\n' print } if or { 'Is equal duppy\n' print } 3 3 == if

I have many other ideas for a stack based scripting language (probably
many of them are bad ideas). I was planning to play with some of these
ideas myself without even bringing them to discussion, but it looks
like, surprisingly, there is some interest in the suckless
community... (although I still have the feeling we should move this
discussion somewhere else).

-- 
- yiyus || JGL . 4l77.com
Received on Wed Aug 25 2010 - 21:51:13 CEST

This archive was generated by hypermail 2.2.0 : Wed Aug 25 2010 - 22:00:04 CEST