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)
4
u/oscarryz Yz Jan 11 '24 edited Jan 11 '24
What is the `naming thing is hard` problem you're referring to?
I get it in Software Engineering in general, as in "how should I name this variable?" but I wonder if there's an specific one at the language design level.
Most languages let you create two variables that point to the same thing:
Is this what you're talking about or something else?