h3rald / min

A small but practical concatenative programming language and shell
https://min-lang.org
MIT License
311 stars 23 forks source link

Let bind and quote-bind put value to top of stack #35

Closed Tyler-Yocolano closed 3 years ago

Tyler-Yocolano commented 6 years ago

What are your thoughts on letting bind (@) and quote-bind (#) put their values on top of the stack?

For example, I have this code:

{} :scores ;empty dict for scores to populate
0 :counter
"abcdefghijklmnopqrstuvwxyz" "" split ;add alphabet to stack
(scores swap counter succ @counter counter swap dset) map ;set each letter to their score

and I thought it might look and feel better as: (scores swap counter succ @counter swap dset) map

Another simpler example is:

1 :x
2 :y
y x + @y x swap
print ;should be 3
h3rald commented 6 years ago

Meh... not sure. The main reason why they don't leave the item on the stack is symmetry with define and quote-define really...

I know that in some situations you'd like to keep the item on the stack to avoid repeating the variable but... is it worth changing the semantics of these operators? Is it more a more frequent use case, also for define and quote-define?

h3rald commented 3 years ago

Closing, not implementing for now.