trueagi-io / hyperon-experimental

MeTTa programming language implementation
https://metta-lang.dev
MIT License
153 stars 50 forks source link

Add a token pattern to form symbols with complex names #519

Open Necr0x0Der opened 11 months ago

Necr0x0Der commented 11 months ago

It might be useful to have a way to specify symbols with names including whitespaces and other symbols, e.g.

`2-LTR circle formation`
vsbogd commented 11 months ago

I would suggest allowing escape sequences in symbols (at the moment they are allowed only in strings) like following:

(= (foo $x) $x)

!(foo ab)    ;[ab]
!(foo a\ b)  ;[a b]
!(foo a b)   ;[(foo a b)]

Also this change should include fix for atom printing procedure to print atom using escaping sequence when whitespace is inside: a\ b.

vsbogd commented 11 months ago

I agree that both syntax forms make sense back quotes and escape sequences. Most important thing to me is that if we allow spaces inside symbols then we need modifying string representation of the symbols accordingly. Otherwise code of the program (foo `a b`) may be printed as (foo a b).