Pages: 1
  Print  
Author Topic: Constants don't work?  (Read 1428 times)
Offline (Unknown gender) daz
Posted on: June 21, 2014, 01:29:16 AM
Contributor
Joined: Jul 2010
Posts: 167

View Profile
I am using latest portable exe (from 6/19) and it appears (user-defined) constants don't work! All constant values are null when I try to print them.

Can these get implemented or fixed?

xoxo,
Daz
Logged
Offline (Unknown gender) egofree
Reply #1 Posted on: June 21, 2014, 02:49:22 AM
Contributor
Joined: Jun 2013
Posts: 603

View Profile Email
Use Enumerations

Quote
Enumerations

As in ISO C++, enumeration values are to be regarded as strict constants. When values are specified, they should be evaluable at the time of parse. A sample enumeration is as follows:
enum {
  a,
  b,
  c,
  d = 10,
  e,
  f
}
In the above enumeration, as per ISO C++, the values of a, b, c, d, e and f are respectively 0, 1, 2, 10, 11, 12. These values should be assigned by the language-independent lexer upon initial parse. The assignment operand for initialized constants is to be regarded as a single token, though it may contain more complex expressions provided that these expressions do not entail runtime computations.
As with EDL structures, EDL enumerations need not be followed by a semicolon, as declarations using the new type must be made separately.

Declarations of enumerations are currently not possible in scripts or objects, however you can include them in definitions, under ENIGMA settings.

http://enigma-dev.org/docs/Wiki/ENIGMA:Specification
Logged
Offline (Unknown gender) daz
Reply #2 Posted on: June 21, 2014, 06:24:09 AM
Contributor
Joined: Jul 2010
Posts: 167

View Profile
While this might be a reasonable substitute, I cannot get it to work either.
Code: [Select]
enum {
UP,
DOWN,
LEFT,
RIGHT,
NONE
}

Error:
Code: [Select]
In file included from SHELLmain.cpp:98:0:
Universal_System/syntax_quirks.h:18:2: error: multiple types in one declaration
 };
Logged
Offline (Unknown gender) egofree
Reply #3 Posted on: June 21, 2014, 08:33:37 AM
Contributor
Joined: Jun 2013
Posts: 603

View Profile Email
If found the problem : it seems enum declarations works only on one line and with a semi-colon at the end. If you try :

Code: [Select]
enum {UP, DOWN, LEFT, RIGHT,NONE};
It should work. Don't ask me why, i didn't make the parser !  ;)
Logged
Offline (Unknown gender) TheExDeus
Reply #4 Posted on: June 21, 2014, 08:59:30 AM

Developer
Joined: Apr 2008
Posts: 1872

View Profile
Quote
It should work. Don't ask me why, i didn't make the parser !  ;)
The code in "Definitions" is not parsed. It needs to be valid C++. In valid C++ you need to have that semicolon at the end (it doesn't matter if it's on one line or several). So it's a typo in the wiki and someone should fix it.
Logged
Offline (Male) Josh @ Dreamland
Reply #5 Posted on: June 21, 2014, 01:22:52 PM

Prince of all Goldfish
Developer
Location: Pittsburgh, PA, USA
Joined: Feb 2008
Posts: 2949

View Profile Email
The parser in the other branch allows enums to be inline in EDL. The wiki page was written for that.
Logged
"That is the single most cryptic piece of code I have ever seen." -Master PobbleWobble
"I disapprove of what you say, but I will defend to the death your right to say it." -Evelyn Beatrice Hall, Friends of Voltaire
Offline (Unknown gender) TheExDeus
Reply #6 Posted on: June 21, 2014, 01:54:18 PM

Developer
Joined: Apr 2008
Posts: 1872

View Profile
When will you finish it and merge it? :|
Logged
Offline (Male) Goombert
Reply #7 Posted on: June 21, 2014, 02:39:10 PM

Developer
Location: Cappuccino, CA
Joined: Jan 2013
Posts: 3107

View Profile
http://enigma-dev.org/docs/wiki/index.php?title=ENIGMA%3ASpecification&action=historysubmit&diff=30333&oldid=30332
Logged
I think it was Leonardo da Vinci who once said something along the lines of "If you build the robots, they will make games." or something to that effect.

Offline (Unknown gender) egofree
Reply #8 Posted on: June 21, 2014, 02:49:26 PM
Contributor
Joined: Jun 2013
Posts: 603

View Profile Email
http://enigma-dev.org/docs/wiki/index.php?title=ENIGMA%3ASpecification&action=historysubmit&diff=30333&oldid=30332

But the example was still not valid. :P So i modified it.  :)
Logged
Pages: 1
  Print