Math notation

Could a set of uni-code characters (e.g. Greek letters) be set to be interpreted as individual variables even if they are next to other characters.

α=2
δ=3
αδ     #6   like 2δ  gives 6 in Julia

Would allow Julia code to look a bit more like math notation.
(though may also be confusing)

2 Likes

This would not be unique, since it is unclear whether you meant to write α*δ which would be defined in you case or the single variable αδ, which would error in you case.

Your proposal would require that variable names that start with greek letters are not allowed to be longer than a single letter, so that would be very limiting (and super breaking to change that now).
I often see Δt which would be forbidden to be used then.

Also – why only limit this to greek letters? Or in other words: also a, C, … are uni-code characters. Who would decide which ones are fine to be allowed only single letters?

7 Likes

You could do that within a macro.

Perhaps nicer (for real numbers) than α*δ :

julia> α'δ
6

Regular non-greek characters, like a, are also unicode characters

julia> 'a'
'a': ASCII/Unicode U+0061 (category Ll: Letter, lowercase)
1 Like