Open edemaine opened 1 year ago
If num²
is equal to num ** 2
, should numᵖᵒʷ
be equal to num ** pow
? Maybe it's not worth it.
Keyword var
is still lacking a shorthand for it though.
I also miss a shorthand for prototype like in CoffeeScript, which uses ::
btW.
And also Python's keyword elif
.
make it configurable so I can use whatever characters and emojis I want, it would be the best feature in Civet
@orenelbaum Thoughts on what this would look like? I wonder if templates (#587) would be a good answer, if you could define your own symbols like so:
template 🧪
try
template 💀
catch
Normally templates can only appear in contexts where function calls can appear, though, so I'm not sure whether this would work without some special casing.
Another option would be to specify simple string replacements, maybe like so:
"civet 🧪='try ' 💀='catch '"
But that seems pretty fragile especially when it comes to spacing.
A few more symbols to consider
||>
to complement ▷<?
as <?
returns true for both x <? SuperClassOfX
and x <? ClassOfX
it somewhat parallels the original meaning of "Subset or equal to")await
I second being able to use templates to define symbols, it would be quite funny to use some geometry in place of the type system keywords like
interface
enum
type
class
Some folks don't use ligatures, but still would like nice notation. Here are some operators that we could support in a simple transpilation sense:
≤
<=
≥
>=
≠
!=
≡
==
(I guess)≣
===
≢
!==
²
** 2
²³
** 23
(ideally)²⁺³
** (2+3)
(ideally)≔
:=
⁇
??
⩲
+=
(I guess)⧺
++
(I guess)‖
\|\|
≪
<<
≫
>>
⋙
>>>
⊕
^
or^^
(maybe, common notation for XOR)¬
!
(maybe)∨
||
(maybe)∧
&&
(maybe)…
...
‥
..
≟
?=
⩻
<?
(instanceof shorthand)∈
is in
∉
is not in
▷
\|>
→
->
⇒
=>
’s
's
“...”
'''...'''
(?)‘...’
'''...'''
Let me know if I missed any! There are some pretty interesting opportunities with shorthand like
∈
. APL here we come.Note: These Unicode characters are relative easy to type using a compose key. On Windows, I use WinCompose, which emulates a feature built into X-Windows (I believe).
This is somewhat related to the (unwritten) proposal to support emoji in identifiers — ideally translating e.g.
😊
tosmiling
or similar, for JS interop, though it might be easier to translate it to something like$1F60A
, to avoid a lookup table. It might be nice to "support" other mathematical operators like≹
as identifiers, so that users can define them viaoperator
. (Or maybe such Unicode operators are automatically infix, but need to be defined viafunction
oroperator
.)