Friendly language syntax #29
Labels
No labels
bug
c:haku
c:rkgk backend
c:rkgk frontend
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference: liquidex/rkgk#29
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
I've been wondering about a syntax friendlier than S-expressions lately.
Style
camelCase
because it's the quickest to type while separating words somewhat. It's not lossless likekebab-case
though, which is annoying, but we wouldn't want to be slowing down users with having to hold Shift to type_
, and-
likewise conflicts with this goal (because you can't do (or even fat-finger)x-y
.)Comments
Lua or Haskell, pick your poison.
Rationale: I don't think
//
or;
would fit the rest of the syntax very well, and I'd like#
for hex RGB(A) literals.Literals
Numbers stay the same, bools are now capitalized.
I'll get to why bools get capitalized now later.
Operators
We now have infix operators.
For now to keep scope down (also we don't have system functions for anything else) we'll have the standard ones:
+
addition-
subtraction and negation*
multiplication/
division==
,!=
(to replace=
and<>
),<
,<=
,>
,>=
!
for inverting a booland
andor
for boolean AND and OROperators may be followed by, but not preceded by newlines.
Lambdas
Roc-inspired:
Zero arguments is not possible with this syntax; a dummy
()
may be passed instead.Calling a lambda does not use any additional delimiters.
Arguments may not span multiple lines. If you find yourself having that many arguments, consider packing them into a data structure for readability.
Conditionals
For now we'll stick with the existing
if
, to be replaced with a pattern-matching construct later.Defs
Using a plain
=
because it's the shortest.Defs are still only allowed before the trailing result expression.
Lets
Syntax is similar to ML, but the
in
is replaced with a newline.If you want multiple lines, wrap your expression in parentheses.
Lists
Instead of the
list
function, you now construct lists using brackets[]
.Newline can serve as an additional separator over commas.
This should make it less annoying to add stuff in the middle of lists or rearrange it, since haku will make some pretty big use of lists for composing scribbles together.
New: tags
Identifiers starting with an uppercase letter are literal tags, which will become useful for representing enums etc. Here are some ideas I had today:
Note how tags can be called just like functions - this allows them to carry a payload (as is the case in that
Ctrl V
example.)New: colors
rgba
colors can be more easily represented using#RRGGBBAA
,#RRGGBB
,#RGBA
, or#RGB
syntax. WhenA
is omitted, it defaults toFF
. This will help with pasting colors from outside pickers.Example
Here's something I sketched up today with ideas from #12.