Ecere SDK/eC Forums http://ecere.com/forums/ Print view |
|
An enum in place of an int http://ecere.com/forums/viewtopic.php?f=2&t=394 |
Page 1 of 1 |
Author: | pber [ Tue Oct 21, 2014 5:55 pm ] |
Post subject: | An enum in place of an int |
Hi Jerome, can I use an enum value where an int was expected? Having: enum DataType { t1, t2 }; and a class class Data { int type; } I can not assign t1 to the type field of an instance of Data. enum DataType : int { t1, t2 }; does not help. PS ...did I ever said eC is great? paolo |
Author: | jerome [ Tue Oct 21, 2014 6:45 pm ] |
Post subject: | Re: An enum in place of an int |
Hi Paolo, Enumerated values will not resolve unless you assign them to an int, they're only visible where their enumeration type is expected. That allows you to have the same enumerated values in different enums (e.g. 'none') If you really want to assign it to an int, you can do: type = DataType::t1; or even: type = (DataType)t1; Yes you did Thanks! How are your eC projects going? Anything interesting to talk about and share with our small community? -Jerome |
Author: | pber [ Tue Oct 21, 2014 7:33 pm ] |
Post subject: | Re: An enum in place of an int |
Hi Jerome, thanks for the hints. In a few days I'll start to publish my toy-project. At now it is able to parse many constructs of an esotic AL (abstract language), more or less eC (without parametric classes). the parser is a hand-written discent parser. And it's still too incomplete to be able to measure its speed with a large code base. A small (and ridicoulously incomplete) VM is already able to perform this: int c; for(c=0; c<1E6; c++); in 60 msecs. Not a record, but it sounds a miracle to me! Today I started the second part (of three) of the game, the QL (query language). It's a lisp-like syntax with which express matching and replacement rules to query and transform the AST. I'm quite happy of the work done till now (even if my code and design is still orrible). Now I try to understand how to upload to github... |
Author: | jerome [ Tue Oct 21, 2014 8:18 pm ] |
Post subject: | Re: An enum in place of an int |
Cool Had you taken a look at my own attempt at a RD parser for eC? https://github.com/ecere/ecere-sdk/tree ... ler/libec2 It is mostly working, just a few language features were missing. I just haven't had time to complete it and make it work together with everything else yet! -Jerome |
Author: | pber [ Tue Oct 21, 2014 9:25 pm ] |
Post subject: | Re: An enum in place of an int |
Your code is always very clean, so that everything seems so simple in eC... I got some errors in ec2 / ASTList (some weeks ago I remember I tried to fix them, maybe now I could be more happy). |
All times are UTC-05:00 | Page 1 of 1 |
Powered by phpBB® Forum Software © phpBB Limited |