Some suggestions...

4 views
Skip to first unread message

Charles Yates

unread,
Mar 24, 2010, 11:51:47 AM3/24/10
to niue-users
Hi,

I like this approach and actually do something similar in the field of
video/audio editing (supplementing literals with strings and video/
audio inputs and operators with filters).

One immediate suggestion - add pick and roll.

Usage for pick:

0 1 2 2 pick == 0 1 2 0

then you can define your some of your standard words as:

: dup 0 pick ;
: over 1 pick ;
: pluck 2 pick ;

and roll becomes:

0 1 2 2 roll == 1 2 0

which is more or less the same as your swap-at I guess? anyway, then
you get:

: noop 0 roll ;
: swap 1 roll ;
: rot 2 roll ;

and you can define other standard forth ones like:

: nip swap drop ;
: tuck swap over ;
: 2dup over over ;
: -rot rot rot ;
: 2swap 3 roll 3 roll ;
: max 2dup < roll drop ;
: min 2dup > roll drop ;
: neg 0 swap - ;
etc

Anyway, looks like an interesting project, and I'm glad it's not just
me that finds stack based languages interesting :-).

Cheers,

Charlie

Message has been deleted

Charles Yates

unread,
Mar 25, 2010, 3:23:47 AM3/25/10
to niue-users
Ah, I had missed the 'at' word...

Sure, go ahead and use em as you like :-).

Cheers,

Charlie

On Mar 25, 5:27 am, Vijay Mathew <vijay.the.sche...@gmail.com> wrote:
> Hello Charles,
>
> Thanks for your favorable comments on Niue and the code snippets! In
> Niue `pick' is called `at' and for roll you have `swap-at'.  Niue, by
> default, don't have an init script, so all primitive words are defined
> in Java.  Of course, a user CAN re-define primitives like 2dup in Niue
> itself and load them from an init script, if he really wants to do
> that!
>
> The examples you gave demonstrates well the philosophy behind small
> but powerful languages like Scheme and Forth -  a data structure + a
> few primitives to manipulate it (e.g car, cdr) + a consistent way to
> represent and invoke functions = a programmable programming language.
>
> To quote directly from R5RS: "Programming languages should be designed
> not by piling feature on top of feature, but by removing the
> weaknesses and restrictions that make additional features appear
> necessary."
>
> BTW, can I use your examples in the tutorial on "Concatenative
> Programming" ?(http://niue.vmathew.in/documentation/concatenative-
> programming)
>
> Thanks,
>
> -- Vijay

Reply all
Reply to author
Forward
0 new messages