Forums

number vs. real poll

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

What is your preference for the name of the re-assignable "decimal point" type?

Poll ended at Sun Jan 04, 2009 4:31 am

number (the current)
3
60%
real (used in Pascal family)
2
40%
 
Total votes : 5

Re: number vs. real poll

Postby Charles » Mon Jan 05, 2009 1:27 pm

If you can set "number" to be "int16" then what happens for this code?
a = 1.4
b = 1.6
c = 0
Charles
 
Posts: 2515
Location: Los Angeles, CA

Re: number vs. real poll

Postby hopscc » Tue Jan 06, 2009 2:49 am

simplistically same as if you'd done
Code: Select all
a as int16 = 1.4
b as int16 = 1.6
c as int16 = 0


or probably more correctly
Code: Select all
a = 1.4 to int16
b = 1.6 to int16
c = 0 to int16


If you setup literals or defaults that dont make sense for the numeric type mapping you still get errors....
hopscc
 
Posts: 632
Location: New Plymouth, Taranaki, New Zealand

Re: number vs. real poll

Postby Charles » Tue Jan 06, 2009 3:33 am

:shock:

"a = 1.6" should not give "1".

-number shall remain an option for fractional values like float and decimal.
Charles
 
Posts: 2515
Location: Los Angeles, CA

Re: number vs. real poll

Postby jonathandavid » Tue Jan 06, 2009 6:18 am

I think what hopscc meant initially is that if the user sets number to int, then functions like "def f(x as number) as number" will take and return an int. This might make sense for applications like number theory in which ints are used all the time, and in which we might be interested in using number for everything and later on decide if we want number to be int, int64, BigInt or whatever.

However, I agree with Chuck that hopscc is wrong in suggesting that code such as "a = 1.6" should lead to "a" taking the type "int". Type inference should be more important in such case. No matter what "number" translates too, "a = 1.6" should always lead to "a" being of a fractional type. Otherwise things would be weird and confusing.
jonathandavid
 
Posts: 159

Re: number vs. real poll

Postby Charles » Tue Jan 06, 2009 10:07 am

jonathandavid wrote:I think what hopscc meant initially is that if the user sets number to int, then functions like "def f(x as number) as number" will take and return an int. This might make sense for applications like number theory in which ints are used all the time, and in which we might be interested in using number for everything and later on decide if we want number to be int, int64, BigInt or whatever.

But for that, I would make "int" configurable as in: cobra -int:int64 ...

Although that seems very low priority compared to other items.
Charles
 
Posts: 2515
Location: Los Angeles, CA

Re: number vs. real poll

Postby jonathandavid » Tue Jan 06, 2009 10:22 am

Chuck wrote:Although that seems very low priority compared to other items.


Agreed.
jonathandavid
 
Posts: 159

Previous

Return to Discussion

Who is online

Users browsing this forum: No registered users and 43 guests