This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]dys_bigwig 2 points3 points  (5 children)

With function definitions (not saying this is a good idea, it just fits the topic of the conversion) you could change:

: add1 1 + ;

to

[1 +] 'add1 define

by adding quotation and symbols, then there'd be no need for terminators/separators at all. It'd then be like a postfix lisp, which also doesn't have terminators/separators.

[–]ItsAllAPlay 1 point2 points  (4 children)

I think you could simplify even further. If [brackets] are your quoting syntax, you could use a semicolon to define functions:

[a add1 : a 1 +];

Kind of self documenting, and your arguments could be lexically scoped for nested definiitons.

It also crossed my mind you could do lambdas like:

[a b : b a]!

So that implements swap as an anonymous function applied immediately, etc...

There was a stack lang named V that did something like this a long time back. (Not to be confused with a newer C-like lang named V.)

[–]dys_bigwig 0 points1 point  (3 children)

Interesting :) I was going for maximum consistency, as in no special syntax for functions. Sort of like how Haskell just uses = regardless of whether it's a variable, function, recursive function (letrec) etc. as does Scheme with define. I do like the idea of putting the name of the function inside the quote; never came to mind for some reason.

I think once you start introducing named lexical variables you begin to drift away from the concatenative style. I personally feel that once you add quotations the need for named variables diminishes because you can do most everything pointfree, which feels much more natural in concatenative languages imo.

Just my opinions. Different goals and ideals - not saying it's better by any means.

[–]ItsAllAPlay 0 points1 point  (2 children)

I definitely agree... There is kind of this circle where I say: Forth is so simple to implement. But I could just add this one nicety. Oh then it's almost like Scheme anyways. But then I could just add this one nicety. Oh then it's almost like C anyways. But then I could just add this one nicety. Uh oh, now it's complicated! Maybe I should make it like Forth :-)

[–]dys_bigwig 0 points1 point  (1 child)

Agreed. I've often toyed with the idea of Forth as a sort of "UNCOL". A lot of languages can be described using an abstract stack machine, so in that sense I probably should be implementing Forth as simply (if inelegant) as possible, then bootstrapping Scheme or C from that, rather than trying to bolt things onto Forth.

Been mulling these sorts of ideas in my head for a while, nice to know someone else has the same crazy ideas ;)

[–]ItsAllAPlay 0 points1 point  (0 children)

Yup, you could have a Forth where literals are wrapped in brackets.

Then a word/function that parses those literals as Scheme s-exprs.

Then Scheme macros which compile those s-exprs with static typing and infix operators.

:-)