Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make , reserved #1528

Closed
mariari opened this issue Sep 13, 2022 · 0 comments
Closed

Make , reserved #1528

mariari opened this issue Sep 13, 2022 · 0 comments

Comments

@mariari
Copy link
Member

mariari commented Sep 13, 2022

The current iteration of Juvix's syntax resembles an ALGOL derivative with inspirations from AGDA. in an ML or ALGOL style syntax, , is often reserved. For ML's , is often reserved so it may be used in literal syntax

ML Syntax

taichi@Gensokyo:~ % rlwrap smlnj
Standard ML of New Jersey (64-bit) v110.99.3 [built: Sat Jul 30 12:02:29 2022]
- [1,2,3];;
val it = [1,2,3] : int list

taichi@Gensokyo:~ % ghci
GHCi, version 9.0.2: https://www.haskell.org/ghc/  :? for help
ghci> :t [1,2,3]
[1,2,3] :: Num a => [a]

Idris> take 10 [1..]
[1, 2, 3, 4, 5, 6, 7, 8, 9, 10] : List Integer
Idris> [2,3]
[2, 3] : List Integer

For OCaml it is used for tuple syntax, however ; happens to be non-clashing enough to use it for list literal syntax.

The odd ML out is Agda which has no literal syntax.

ALGOL syntax

In the ALGOL family, , use is ubiquitous, with , coming in for function separation, and even for array literals

int num[] = {1, 2, 3, 4, 5};
assertEquals(num, num);

Other Families

With that said, there are some families that do not reserve ,. These are typically the forth family and the hoon family. hoon uses , as a normal rune, and as for factor, I can have symbols like

IN: scratchpad 1 20 [a,b) interval>points

--- Data stack:
{ 1 t }
{ 20 f }

because words are separated by spaces. The [a,b) word can be found here.

This is because the syntax's are truly minimal, and thus no tension is had, as they aren't expected by convention to be reserved by the language creators.

The Lisp family often reserves , in the pre defined reader macro set as they serve as a useful function in the quasi quotation reader macro. However even with that said, a language like Clojure has explicitly made , whitespace in order to make people familiar with other lanugages on the JVM feel more at home

user=> (def m {:a 1, :b 2, :c 3})
{:a 1, :b 2, :c 3}

This has a few issues with people coming from other lisps, however that is not relevant in this current case.

Compounding Factors

I believe in issue #1495 the issue makes itself present, with patch #1525 relieving the tension. However, if , was reserved no special patch would be needed.

Further I would like to argue that one should be conservative on what symbols are not reserved, as in the future , and other key symbols may be needed to disambiguate syntax. The current iteration of Juvix may further down the line want record literal syntax, hash table syntax, etc. Without , reserved, then one may have to rely on ; which may be overloaded in such a way to cause ambiguity issues. Thus I think it is prudent to reserve symbols like ,, @, ~ as special prematurely to later be spent when the opportunity arises (or give back if no such opportunity is found).

Conclusion

Make , reserved, have it be used for list literal syntax. Further, push the concept and try to think of record literal syntax in the future with the use of ,. ; may be too overloaded by that point to be useful for record syntax, and a reserved symbol ought to be used.

@mariari mariari added enhancement New feature or request language syntax labels Sep 13, 2022
@lukaszcz lukaszcz added this to the 0.4 milestone Jan 24, 2023
@paulcadman paulcadman modified the milestones: 0.4.1, 0.4.2 Jun 23, 2023
@jonaprieto jonaprieto removed this from the 0.4.2 milestone Jul 24, 2023
@paulcadman paulcadman closed this as not planned Won't fix, can't repro, duplicate, stale Jun 19, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants