Forums

Specifying type of Integer Literals

General discussion about Cobra. Releases and general news will also be posted here.
Feel free to ask questions or just say "Hello".

Specifying type of Integer Literals

Postby hopscc » Tue Apr 29, 2008 4:16 am

There was some discussion a while ago about specifying the type of a fractional literal ( decimal, float) using various suffixes
(see "New Number type and -number:type option" topic)

I thought a logical extension of that would be to allow suffixes for integer literals to specify size and sign so that rather than
this sort of casting redundancy
Code: Select all
a as int64 = 1000 as int64
l = 73 as int64

you could do something 'nicer' :) like this
Code: Select all
a as int64 = 1000_i64
l as int64 = 73_i64
# or more conveniently
l = 73_i64


Heres a patch that supports int literals with a suffix (i|_i)(8,16,32,64)? or (u|_u)(8,16,32,64).
Attachments
intLitSized.patch
patch supporting suffixes for int literals
(2.65 KiB) Downloaded 597 times
hopscc
 
Posts: 632
Location: New Plymouth, Taranaki, New Zealand

Re: Specifying type of Integer Literals

Postby hopscc » Tue Apr 29, 2008 5:07 am

And heres the test file
Attachments
ilit.cobra
(1.87 KiB) Downloaded 594 times
hopscc
 
Posts: 632
Location: New Plymouth, Taranaki, New Zealand

Re: Specifying type of Integer Literals

Postby Charles » Tue Apr 29, 2008 7:33 am

Thanks. I'll take a look this week.
Charles
 
Posts: 2515
Location: Los Angeles, CA

Re: Specifying type of Integer Literals

Postby Charles » Sat May 03, 2008 2:27 pm

Applied. Thanks.
Charles
 
Posts: 2515
Location: Los Angeles, CA


Return to Discussion

Who is online

Users browsing this forum: No registered users and 25 guests