-
-
Notifications
You must be signed in to change notification settings - Fork 4
alias
Aliases are an important mechanism in angle to norm synonyms.
The idea is that developers don't need to memorize specific variants (length, size, count) but are directed to the standard (correct/main) form. The normed synonym is handled at an early system level, similar to how in python the '+' operator resolves to the method 'add' on objects.
If an object defines any synonym (e.g. one of length, size, count), this property can be accessed via all forms of its aliases.
If an object defines multiple synonymous properties (e.g. length, size, count) these can still be used individually. A compiler warning may be emitted, warning developers that they are overloading aliases.
aliases can be added at compile time and runtime via keyword alias
:
alias length = count
or
alias length => count
to indicate the standard form.
internal keywords can have aliases too, similar to c's #define
, but they need to be quoted as symbol :
alias typedef => :alias
same syntax as other aliases:
alias u32 => unsigned int
alias i32u => u32
#operator alias are important for unicode : The following shall be mapped early to minus early in parsing:
0x2010 8208 HYPHEN ‐
0x2011 8209 NON-BREAKING HYPHEN ‑
0x2012 8210 FIGURE DASH ‒
0x2013 8211 EN DASH –
0x2014 8212 EM DASH —
0x2015 8213 HORIZONTAL BAR ―
etc
range
To express aliases inside wast/wasm use the _alias_
naming convention prefix:
(export "log10" (func $log10))
(export "_alias_log₁₀" (func $log10))
(export "_alias_₁₀⌞" (func $log10))
(export "_alias_10⌞" (func $log10))
Angle takes care of the semantics.
(export "log10" (func $log10))
.
Ugly workaround: (export "_alias_log₁₀__log10")
when to warn developers about the standard form and when not:
1. convert this log₁₀ to log10
2. convert all log₁₀ to log10
3. convert this log10 to log₁₀
4. convert all log10 to log₁₀
5. ignore this
6. ignore all alias warnings for log₁₀
Your choice will be stored in alias-preferences.wasp and can be edited any time.
Your preferences it will still be normed to the Angle default standard alias when using git.
"```