Complexity Shock Horror II: the Sequel (was Re: MD5 in erlang
    Tony Rogvall 
    tony@REDACTED
       
    Mon Mar 31 13:44:09 CEST 2003
    
    
  
Raimo Niskanen wrote:
> 
> I am about to add your requested functionality to io_lib:format, so I 
> thought about adding these BIFs too, but it turned out that it was hard 
> to decide what they should do, exactly: Erlang-style prefix or not, 
> lowercase or UPPERCASE or selectable and how to select, how to select 
> any-base for list_to_integer/2, etc.
> 
> It started to seem that an option list was needed with quite some 
> options, and then they suddenly did seem too complicated to be BIFs.
> 
Here is one suggestion for R9C
integer_to_list(Integer, Base)
where integer(Integer) and Base = bin | oct | hex or dec
- The prefix is not needed sice it is a constant op to cons "16#" or 
whatever as a prefix.
- The case is not very important for hex numbers since most "readers" 
can read both upper an lower case, correct me I you ever seen any 
software (not your own:-) that care about case in hex numbers! . I vote 
for uppercase, since that what is what I have seen most. If it should be 
a problem then we can add 'heX' as uppercase option.
I wonder how many times I have written integer_to_hex? I am sure it must 
be 100 times...
When we are at it, why not do the same thing for list_to_integer?
I suggest:
	 list_to_integer(List, Base)  (base = bin | oct | hex | dec )
possibly allowing base spec in the list_to_integer/1 i.e 
list_to_integer("16#1234")
Raimo you can give me a call, I will be glad to help you :-)
> So I hope it will do to use something like 
> lists:flatten(io_lib:format("~16b", [Integer])).
> 
> If it is necessary for performance reasons, we might add these BIFs later.
> 
Why wait ? I do not think we can talk us out of this one :-)
/Tony
-------------- next part --------------
A non-text attachment was scrubbed...
Name: smime.p7s
Type: application/x-pkcs7-signature
Size: 3237 bytes
Desc: S/MIME Cryptographic Signature
URL: <http://erlang.org/pipermail/erlang-questions/attachments/20030331/1e693e19/attachment.bin>
    
    
More information about the erlang-questions
mailing list