On Wed, 12 May 2010, Mindaugas Kavaliauskas wrote:

Hi,

> perhaps this is a known issue, but looks like a strange limitation
> of __enumKey() message. This code could not be compiled because of:
> test202.prg(5) Warning W0031  Invalid variable 'XVALUE' for
> enumerator message
> FUNC main()
> LOCAL xValue
>   FOR EACH xValue IN {'a'=>'A', 'b'=>'B'}
>     ? xValue:__enumKey()
>     ? EVAL({|| xValue:__enumKey()})
>   NEXT
> RETURN NIL

It's intentional. You cannot eat cake and have cake ;-)
Most of people (at least those who asked about it in the past) prefer
that codeblocks detach enumerated values not enumerators itself.
This example illustrate it:

   FUNC main()
   LOCAL xValue, aCode := {}
     FOR EACH xValue IN {'a'=>'A', 'b'=>'B'}
       AADD( aCode, {|| xValue } )
     NEXT
     AEVAL( aCode, { |x| QOUT( EVAL( x ) ) } )
   RETURN NIL

and for such behavior the above warning is correct.

best regards,
Przemek
_______________________________________________
Harbour mailing list (attachment size limit: 40KB)
Harbour@harbour-project.org
http://lists.harbour-project.org/mailman/listinfo/harbour

Reply via email to