On Mon, 27 Oct 2008, Szak�ts Viktor wrote:

Hi Viktor,

>>> This is Harbour .prg code.
>> So please refresh in your mind what && does in .prg code ;-)
> That's why I was asking if I was missing something :/
> I fully thought we replicated the C way of #defines,
> and I'm a bit puzzled on this syntax :(

Because it is fully replicated. There is even code like:
   case HB_PP_TOKEN_AMPERSAND:
      *piNextPrec = HB_PP_PREC_BIT;
      /* It will not work because && will be stripped as comment */
      if( pNext && HB_PP_TOKEN_TYPE( pNext->type ) == HB_PP_TOKEN_AMPERSAND &&
          pNext->spaces == 0 )
      {
         *piNextOper = HB_PP_TOKEN_AND;
         pNext = pNext->pNext;
      }
      break;

See the comment. To be precise this code can be activated in some cases
when #if will be result of some other PP directives.
The problem is that before we reach this state we have to strip code
after && because it needs very high priority for full Clipper compatibility
otherwise it will introduce series of small incompatibilities.
I can hardcode in PP that && is not a comment for lines starting with #if
but it may confuse users even more.

> [ There are probably some reasons for this, but I fully
> forgot about the whole topic. ]

The only one reason is strict Clipper compatibility.

> Okay, many thanks, I'll need this:
> '#if defined( DEF_A ) .and. .not. defined( DEF_B )'
> This seems to work okay.

You can use '!' instead of .not.
Problematic is only '&&' because in Clipper it has special meaning.
It's comment marker with the same priority as // and lower priority
then /* */
People also used to forgot about yet another type of comment in Clipper: NOTE
Clipper documents it wrongly as command but it's not a command in Clipper
but special type of comment in Clipper's PP parser.
This code should illustrate different problems with comments interpretation:

   #command COMMENT <*x*> => NOTE <x>
   proc main()
      ? && It's a comment
      ? /* && "Test" */ "Test"
      ? && /* && "Test"
        */ "Test"
      ? // /* && "Test"
        */ "Test"
      NOTE It's a comment
      COMMENT It's a comment which does not work because NOTE is not command
   return

Try to compile the code by Harbour and Clipper and compare -p results.
As you should see Harbour is fully Clipper compatible and even PP and
compiler error messages are compatible though literally not the same.

best regards,
Przemek
_______________________________________________
Harbour mailing list
Harbour@harbour-project.org
http://lists.harbour-project.org/mailman/listinfo/harbour

Reply via email to