Pages: 1
Author Topic: Constants don't work?  (61,693 Views)
Offline (Unknown gender) daz

Contributor
Joined: Jul 2010
Posts: 167
View profile
Posted on: June 21, 2014, 06:29:16 AM
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
Offline (Unknown gender) egofree

Contributor
Joined: Jun 2013
Posts: 601
View profile
Reply #1 Posted on: June 21, 2014, 07:49:22 AM
Use Enumerations

QuoteEnumerations

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
Offline (Unknown gender) daz

Contributor
Joined: Jul 2010
Posts: 167
View profile
Reply #2 Posted on: June 21, 2014, 11:24:09 AM
While this might be a reasonable substitute, I cannot get it to work either.

enum {
UP,
DOWN,
LEFT,
RIGHT,
NONE
}


Error:
In file included from SHELLmain.cpp:98:0:
Universal_System/syntax_quirks.h:18:2: error: multiple types in one declaration
};
Offline (Unknown gender) egofree

Contributor
Joined: Jun 2013
Posts: 601
View profile
Reply #3 Posted on: June 21, 2014, 01:33:37 PM
If found the problem : it seems enum declarations works only on one line and with a semi-colon at the end. If you try :

enum {UP, DOWN, LEFT, RIGHT,NONE};

It should work. Don't ask me why, i didn't make the parser !  ;)
Offline (Unknown gender) TheExDeus

Developer
Joined: Apr 2008
Posts: 1,860
View profile
Reply #4 Posted on: June 21, 2014, 01:59:30 PM
QuoteIt 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.
Offline (Unknown gender) Josh @ Dreamland

Prince of all Goldfish
Developer
Joined: Feb 2008
Posts: 2,950
View profile
Reply #5 Posted on: June 21, 2014, 06:22:52 PM
The parser in the other branch allows enums to be inline in EDL. The wiki page was written for that.
Offline (Unknown gender) TheExDeus

Developer
Joined: Apr 2008
Posts: 1,860
View profile
Reply #6 Posted on: June 21, 2014, 06:54:18 PM
When will you finish it and merge it? :|
Offline (Unknown gender) Goombert

Developer
Joined: Jan 2013
Posts: 2,991
View profile
Reply #7 Posted on: June 21, 2014, 07:39:10 PM
http://enigma-dev.org/docs/wiki/index.php?title=ENIGMA%3ASpecification&action=historysubmit&diff=30333&oldid=30332
Offline (Unknown gender) egofree

Contributor
Joined: Jun 2013
Posts: 601
View profile
Reply #8 Posted on: June 21, 2014, 07:49:26 PM
Quote from: Robert B Colton on June 21, 2014, 07:39:10 PM
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.  :)
Pages: 1