I have found that when trying to declare a decimal literal, such as -100000000d, I get an error: 'Expecting EOL, but got "d" (ID) instead.' This is easily resolved by adding a period and a zero: -100000000.0d
Despite there being an easy resolution, I'm unsure why it is required to have a .0 for decimal literals. Given that Cobra is very smart about figuring many other things out, why isn't it smart enough to treat it as a decimal w/o choking? Is this something I should write a bug for, or is it WAD?
Forums
Decimal Literal
10 posts
• Page 1 of 1
Re: Decimal Literal
I can't think of any problems with whole number literals having suffixes like d, f32, f64 and f to set their type. Any objections?
Should we also have "n" for "number" which is a type in Cobra?
Should we also have "n" for "number" which is a type in Cobra?
- Charles
- Posts: 2515
- Location: Los Angeles, CA
Re: Decimal Literal
We definitely need one for byte/uint8. Will come in handy for byte arrays.
- todd.a
- Site Admin
- Posts: 81
- Location: Chicago, IL
Re: Decimal Literal
We already have that covered:
x = 5u8
trace x
# outputs:
# trace: x=5 (Byte); at ...
- Charles
- Posts: 2515
- Location: Los Angeles, CA
Re: Decimal Literal
Done in changeset:2467:
Please test it and let me know how it goes.
Support numeric literals like `45n` for `number` and `45d` for decimal. Previously, the `d` suffix required a decimal portion (`45.0d`) and there was no `n` suffix available.
reported-by:torial
Please test it and let me know how it goes.
- Charles
- Posts: 2515
- Location: Los Angeles, CA
Re: Decimal Literal
It seems since that patch the cobra tests fail - specifically Tests/110-basics-two/110-int-types.cobra
- Code: Select all
RUN ..\Tests\110-basics-two\110-int-types.cobra
C:\home\hops\src\cobra\wkspace1\Source\..\Tests\110-basics-two\110-int-types.cobra
Test #1
----------------------------------------------------------------------------------------------------
----------------------------------------------------------------------------------------------------
Skipping duplicate message: c:\home\hops\src\cobra\wkspace1\Tests\tests\110-basics-two\110-int-types.cobra(185): error: The call is ambiguous between the following methods or properties: "Cobra.Lang.CobraImp.IsTrue(float?)" and "Cobra.Lang.CobraImp.IsTrue(decimal?)" (C#)
Skipping duplicate message: c:\home\hops\src\cobra\wkspace1\Tests\tests\110-basics-two\110-int-types.cobra(187): error: The call is ambiguous between the following methods or properties: "Cobra.Lang.CobraImp.IsTrue(float?)" and "Cobra.Lang.CobraImp.IsTrue(decimal?)" (C#)
Skipping duplicate message: c:\home\hops\src\cobra\wkspace1\Tests\tests\110-basics-two\110-int-types.cobra(219): error: The call is ambiguous between the following methods or properties: "Cobra.Lang.CobraImp.IsTrue(float?)" and "Cobra.Lang.CobraImp.IsTrue(decimal?)" (C#)
Skipping duplicate message: c:\home\hops\src\cobra\wkspace1\Tests\tests\110-basics-two\110-int-types.cobra(221): error: The call is ambiguous between the following methods or properties: "Cobra.Lang.CobraImp.IsTrue(float?)" and "Cobra.Lang.CobraImp.IsTrue(decimal?)" (C#)
Skipping duplicate message: c:\home\hops\src\cobra\wkspace1\Tests\tests\110-basics-two\110-int-types.cobra(236): error: The call is ambiguous between the following methods or properties: "Cobra.Lang.CobraImp.IsTrue(float?)" and "Cobra.Lang.CobraImp.IsTrue(decimal?)" (C#)
Skipping duplicate message: c:\home\hops\src\cobra\wkspace1\Tests\tests\110-basics-two\110-int-types.cobra(238): error: The call is ambiguous between the following methods or properties: "Cobra.Lang.CobraImp.IsTrue(float?)" and "Cobra.Lang.CobraImp.IsTrue(decimal?)" (C#)
Skipping duplicate message: c:\home\hops\src\cobra\wkspace1\Tests\tests\110-basics-two\110-int-types.cobra(253): error: The call is ambiguous between the following methods or properties: "Cobra.Lang.CobraImp.IsTrue(float?)" and "Cobra.Lang.CobraImp.IsTrue(decimal?)" (C#)
Skipping duplicate message: c:\home\hops\src\cobra\wkspace1\Tests\tests\110-basics-two\110-int-types.cobra(255): error: The call is ambiguous between the following methods or properties: "Cobra.Lang.CobraImp.IsTrue(float?)" and "Cobra.Lang.CobraImp.IsTrue(decimal?)" (C#)
c:\home\hops\src\cobra\wkspace1\Tests\tests\110-basics-two\110-int-types.cobra(185): error: The call is ambiguous between the following methods or properties: "Cobra.Lang.CobraImp.IsTrue(float?)" and "Cobra.Lang.CobraImp.IsTrue(decimal?)" (C#)
c:\home\hops\src\cobra\wkspace1\Tests\tests\110-basics-two\110-int-types.cobra(187): error: The call is ambiguous between the following methods or properties: "Cobra.Lang.CobraImp.IsTrue(float?)" and "Cobra.Lang.CobraImp.IsTrue(decimal?)" (C#)
c:\home\hops\src\cobra\wkspace1\Tests\tests\110-basics-two\110-int-types.cobra(189): error: The call is ambiguous between the following methods or properties: "Cobra.Lang.CobraImp.IsTrue(float?)" and "Cobra.Lang.CobraImp.IsTrue(decimal?)" (C#)
c:\home\hops\src\cobra\wkspace1\Tests\tests\110-basics-two\110-int-types.cobra(219): error: The call is ambiguous between the following methods or properties: "Cobra.Lang.CobraImp.IsTrue(float?)" and "Cobra.Lang.CobraImp.IsTrue(decimal?)" (C#)
c:\home\hops\src\cobra\wkspace1\Tests\tests\110-basics-two\110-int-types.cobra(221): error: The call is ambiguous between the following methods or properties: "Cobra.Lang.CobraImp.IsTrue(float?)" and "Cobra.Lang.CobraImp.IsTrue(decimal?)" (C#)
c:\home\hops\src\cobra\wkspace1\Tests\tests\110-basics-two\110-int-types.cobra(223): error: The call is ambiguous between the following methods or properties: "Cobra.Lang.CobraImp.IsTrue(float?)" and "Cobra.Lang.CobraImp.IsTrue(decimal?)" (C#)
c:\home\hops\src\cobra\wkspace1\Tests\tests\110-basics-two\110-int-types.cobra(236): error: The call is ambiguous between the following methods or properties: "Cobra.Lang.CobraImp.IsTrue(float?)" and "Cobra.Lang.CobraImp.IsTrue(decimal?)" (C#)
c:\home\hops\src\cobra\wkspace1\Tests\tests\110-basics-two\110-int-types.cobra(238): error: The call is ambiguous between the following methods or properties: "Cobra.Lang.CobraImp.IsTrue(float?)" and "Cobra.Lang.CobraImp.IsTrue(decimal?)" (C#)
c:\home\hops\src\cobra\wkspace1\Tests\tests\110-basics-two\110-int-types.cobra(240): error: The call is ambiguous between the following methods or properties: "Cobra.Lang.CobraImp.IsTrue(float?)" and "Cobra.Lang.CobraImp.IsTrue(decimal?)" (C#)
c:\home\hops\src\cobra\wkspace1\Tests\tests\110-basics-two\110-int-types.cobra(242): error: The call is ambiguous between the following methods or properties: "Cobra.Lang.CobraImp.IsTrue(float?)" and "Cobra.Lang.CobraImp.IsTrue(decimal?)" (C#)
c:\home\hops\src\cobra\wkspace1\Tests\tests\110-basics-two\110-int-types.cobra(253): error: The call is ambiguous between the following methods or properties: "Cobra.Lang.CobraImp.IsTrue(float?)" and "Cobra.Lang.CobraImp.IsTrue(decimal?)" (C#)
c:\home\hops\src\cobra\wkspace1\Tests\tests\110-basics-two\110-int-types.cobra(255): error: The call is ambiguous between the following methods or properties: "Cobra.Lang.CobraImp.IsTrue(float?)" and "Cobra.Lang.CobraImp.IsTrue(decimal?)" (C#)
c:\home\hops\src\cobra\wkspace1\Tests\tests\110-basics-two\110-int-types.cobra(257): error: The call is ambiguous between the following methods or properties: "Cobra.Lang.CobraImp.IsTrue(float?)" and "Cobra.Lang.CobraImp.IsTrue(decimal?)" (C#)
Compilation failed - 13 errors, 0 warnings
----------------------------------------------------------------------------------------------------
- hopscc
- Posts: 632
- Location: New Plymouth, Taranaki, New Zealand
Re: Decimal Literal
Did you do a "cobra -bsl" to produce a new Cobra.Lang.dll? I think this is the problem.
- Charles
- Posts: 2515
- Location: Los Angeles, CA
Re: Decimal Literal
My apologies, so it is
- hopscc
- Posts: 632
- Location: New Plymouth, Taranaki, New Zealand
10 posts
• Page 1 of 1
Who is online
Users browsing this forum: No registered users and 47 guests