h3rald / min

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

dset and interpolate both use % #19

Closed mwgkgk closed 6 years ago

mwgkgk commented 6 years ago

In the docs, % is the symbol for both interpolate and dset. In the source:

lib/min_str.nim

def.symbol("%") do (i: In):
i.push("interpolate".newSym)

lib/min_seq.nim

def.sigil("%") do (i: In):
i.push("dset".newSym)

In practice interpolate is the one that gets called.

h3rald commented 6 years ago

Mmmm not quite. The % symbol is used for interpolate, while the % sigil is used for dset.

In other words:

 "Hello, $1!" ("World") %  ;interpolate symbol, outputs "Hello, World!"

...but:

 () 10 %test ;dset sigil, outputs (("test" 10))

Now... OK, min does get a little bit confusing when the same character is used for a symbol and a sigil that does something completely different, I know... :( The same applies to the following symbols as well:

 > < / +

The corresponding sigils are used as shorthands for, respectively:

 save-symbol load-symbol dget module
mwgkgk commented 6 years ago

Wow! I didn't realize I was trying to call it wrong. My bad. Thank you! <3