You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm proud of what I built. Now that we have something working. It is time to think a bit more carefully about the chirp and dsl! syntax.
Summary of proposed syntax changes and poll at the end.
Note that I will only consider winners if there are in my preference list or someone made a compelling argument in its favor.
What's chirp and dsl! syntax
It is the shared syntax used in the dsl! macro from cuicui_dsl and the .chirp file format in cuicui_chirp.
The two share — if not the exact same syntax — a similar enough syntax that it should be possible to copy/paste your dsl! macro content into an independent file and load it as a .chirp file using asset_server.load::<Chirp, _>("scene.chirp").
I already like the syntax, but it might be offputting to some for the following reasons:
Method call without parenthesis (eg: empty_px 60 "calls" the empty_px method with argument 60)
string literal as name (the fact that "10 wow" and rules(10px, 11%) can be at the same location as syntax elements)
Two ways of calling a method (eg: row("10", margin 10) is equivalent to entity("10", margin 10, row)
Some people are hermetic to the concept of anything else but HTML being used to define UIs
While I can't solve (4), I plan to fix the other 3 points.
The current syntax is not exactly completely alien, especially for UI. It comes from:
QML: the javascript inspired markup for Qt's new UI declaration system
KDL: The node-based markup similar to Dlang's config.
text FBX: yep, it does look an awful lot like the chirp syntax, doesn't it?
This is not up to debate. I will replace the "parent node syntax" by entity name declaration & remove the literal syntax for names. So the previous snippet will look as follow:
One issue with this is that with large method lists that span several lines,
it might be difficult to distinguish a method call from a statement. Only
hint is that we don't terminate with a ; or {}.
Though this is true of every other proposed syntaxes as well.
We could also remove ; for the same reason we can remove ,. This can't
be done without the parenthesis around the method list.
Another issue is syntax error detection: entity(method1 arg1) is valid
syntax, but it is two methods, not a single one with two arguments.
It's a bad result if someone forgot to add a : between the method and its
single argument.
But the error message might be good enough to get the hint to people.
We could just drop the : style to avoid the pitfall.
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
I'm proud of what I built. Now that we have something working. It is time to think a bit more carefully about the
chirp
anddsl!
syntax.Summary of proposed syntax changes and poll at the end.
Note that I will only consider winners if there are in my preference list or someone made a compelling argument in its favor.
What's
chirp
anddsl!
syntaxIt is the shared syntax used in the
dsl!
macro fromcuicui_dsl
and the.chirp
file format incuicui_chirp
.The two share — if not the exact same syntax — a similar enough syntax that it should be possible to copy/paste your
dsl!
macro content into an independent file and load it as a.chirp
file usingasset_server.load::<Chirp, _>("scene.chirp")
.The current syntax is as follow:
Planned syntax
I already like the syntax, but it might be offputting to some for the following reasons:
empty_px 60
"calls" theempty_px
method with argument60
)"10 wow"
andrules(10px, 11%)
can be at the same location as syntax elements)row("10", margin 10)
is equivalent toentity("10", margin 10, row)
While I can't solve (4), I plan to fix the other 3 points.
The current syntax is not exactly completely alien, especially for UI. It comes from:
This is not up to debate. I will replace the "parent node syntax" by entity name declaration & remove the literal syntax for names. So the previous snippet will look as follow:
The name, instead of being a method special-case, will be the "head identifier" of a statement.
The question is: can I do better for the rest of the grammar. Can it be more familiar for users?
Original
KDL-light
must use parenthesis
KDL-light with method commas
KDL-light with equal
KDL-light with colon
After looking at those, I feel like keeping the parenthesis around the
method list is ve3ry useful in term of readability.
OG-dsl without commas but with colons
One issue with this is that with large method lists that span several lines,
it might be difficult to distinguish a method call from a statement. Only
hint is that we don't terminate with a
;
or{}
.Though this is true of every other proposed syntaxes as well.
We could also remove
;
for the same reason we can remove,
. This can'tbe done without the parenthesis around the method list.
Another issue is syntax error detection:
entity(method1 arg1)
is validsyntax, but it is two methods, not a single one with two arguments.
It's a bad result if someone forgot to add a
:
between the method and itssingle argument.
But the error message might be good enough to get the hint to people.
We could just drop the
:
style to avoid the pitfall.OG-dsl without commas nor semicolons nor colons
It's much cleaner and we don't lose on readability.
I just think forcing the
()
on single-argument methods is too noisy.Especially when most methods will have 0 or 1 argument.
Though not having a magic syntax for single arg methods is appealing
OG-dsl without commas nor semicolons, but with colons
Removing commas turns out to be very confusing with semicolons.
OG-dsl without commas nor semicolons, but with equals
Removing commas turns out to be very confusing with semicolons. We can however
use
=
to visually put together methods and their signle argumentSummary
Original
()
around method list,
between methods;
between leaf statements;
and,
are noisy, 1arg method is surprising coming from Algol-likeKDL-light
()
around method list,
between methods()
;
between leaf statementsLack of symmetry between methods and statements,
;
is noisy,()
for1arg methods noisy
KDL-light with method commas
()
around method list,
between methods;
between leaf statementsLack of symmetry between methods and statements,
;
and,
are noisy, 1arg method is surprising coming from Algol-likeKDL-light with equal
()
around method list,
between methods=
;
between leaf statementsCloser to KDL, Lack of symmetry between methods and statements,
;
is noisyKDL-light with colon
()
around method list,
between methods:
;
between leaf statementsCloser to JSON, Lack of symmetry between methods and statements,
;
is noisy. Two subsequent 1arg methods without,
between them is veryconfusing
OG-dsl without commas but with colons
()
around method list,
between methods:
;
between leaf statementsSymmetry between methods and statements,
;
is noisy,Two subsequent 1arg methods without
,
between them is veryconfusing.
OG-dsl without commas nor semicolons nor colons
()
around method list,
between methods()
;
between leaf statementsBest symmetry between methods and statements,
()
for 1arg methods noisy.OG-dsl without commas nor semicolons, but with colons
()
around method list,
between methods:
;
between leaf statementsSymmetry between methods and statements,
Two subsequent 1arg methods without
,
between them is veryconfusing.
OG-dsl without commas nor semicolons, but with equals
()
around method list,
between methods=
;
between leaf statementsSymmetry between methods and statements.
Personal ranking
Any other feel just so wrong to me.
1 vote ·
Beta Was this translation helpful? Give feedback.
All reactions