Syntactic sugar poll

Erik.Johansson Erik.Johansson@REDACTED
Fri Jan 11 14:09:12 CET 2002

I have a suggestion for a very small change that seems to arouse strong feelings.

Since I am doing a lot of assembly hacking I often need to use hexadecimal constants. All my debuggers and C compilers write hexadecimal constants as 0xN, but in Erlang I have to write it as 16#N. There are two problems with this, I can not copy and paste hexadecimal numbers between Erlang and other applications, and it looks really ugly. Now, don't get me wrong the general base#number syntax is flexible and useful but would it not be nice to have 0xN as syntactic sugar for 16#N in Erlang. 

What do you think? Would it be nice to have this feature? 
Are there any reasons for not allowing this feature?

I use it in the shell in my system (together with my fixes for printing hexadecimal numbers) but since it is not a part of standard Erlang I can't use it in Erlang code that I write (at least not in portable code ;) which is a shame.

All that is need to get it to work is this little patch:
+ scan_after_int([$x|Cs], Ncs, Toks, SPos, CPos) ->
+     case list_to_integer(reverse(Ncs)) of
+       0 ->
+           scan_based_int(Cs, 0, 16, Toks, SPos, CPos);
+       Base ->
+           scan_error({base,Base}, CPos)
+     end;
Please, support this bill today!

 N. Erik M. Johansson
  Studentvägen 13:33
  752 34 Uppsala (Sweden)
 Work: +46 - (0)18 - 4711 033
 GSM : +46 - (0)70 - 631 42 59
 Home: +46 - (0)18 - 51 13 29 
 Eric Conspiracy Secret Laboratories       
I'm Happi, you should be happy.
Praeterea censeo 0xCA scribere Erlang posse.

More information about the erlang-questions mailing list