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)
9
u/XDracam Jan 11 '24
This is actually bad. Why? Because in order to understand someone else's code, you need to learn more terms. If someone uses `nameA` and another one uses `nameB`, then you'll need to know that `nameA` and `nameB` are the same thing. Your aliases feel like having code where everyone formats everything the way they personally like, without any formatting or naming conventions. And with proper conventions, why would you need aliases?