[futurebasic] Re: [FB] FBtoC feature request

Message: < previous - next > : Reply : Subscribe : Cleanse
Home   : July 2011 : Group Archive : Group : All Groups

From: Robert Purves <listrp@...>
Date: Tue, 26 Jul 2011 17:32:17 +1200
I wrote:
> Technically it would be easy to translate
>    _foo = 42
> as
>    enum { foo = 42 };
> and then emit 'foo' instead of 42 in the translation.
> But constants like this
>    _kCFNetDiagnosticConnectionUp = -66559
> must not be emitted as an enum, because kCFNetDiagnosticConnectionUp is already known to the compiler. Marking all such constants as 'no-enum' would possibly be a impracticable task, and certainly a huge one.

Brian S. suggested that new forms of 'begin enum' be used to indicate constants to be emitted as symbols. Such new forms avoid all mass conversion tasks, and took only a couple of hours to implement for the next release of FB. Existing code will continue to work as before.


Symbolicate and emit 'enum'.
'---------------------
begin enum output
  _foo
  _bar = 9999
end enum

if ( _foo == _bar ) then ...
'---------------------

C translation:

  enum { foo = 0 }; 
  enum { bar = 9999 }; 

  if ( foo == bar ) {...}



Symbolicate but don't emit 'enum'.
'---------------------
begin enum not output
  _kCFNetDiagnosticConnectionUp = -66559
end enum
'---------------------


Robert P.