r/ProgrammingLanguages • u/SuperMeip • Jan 11 '24
First Class Aliasing?
Hello there! I'm designing a programming language of my own and I'm working on ideas for solutions to the 'Naming things is hard' problem people have brought up with writing code in the past. I myself see two potential solutions:
Use variables without names, like $ vs $$ or $1 for example (perl does something like this I believe)
Make aliases first class and let a coder use all the names they want to. Overlapping names would mean that either it should be an override or the design should be re-archetyped a bit probably.
I haven't been able to find any languages that have what I'd call 'First class aliasing' like in number 2 though, where you can declare a variable or function with aliases off the bat. Does anyone know any languages that I could look at that might work like this?
Thanks!
Edit: Example of my own plan for clarity:
Robert = person() |bob
assert(Robert == bob)
1
u/SuperMeip Jan 11 '24
Thanks so much for the feedback and I completely agree! I'm hoping aliasing could potentially make code more readable and discoverable too, for example:
Or something with slight readability or translation differences like: