jed-users mailing list

[2005 Date Index] [2005 Thread Index] [Other years]
[Thread Prev] [Thread Next]      [Date Prev] [Date Next]

Re: problem with preparsing and #ifeval


On  7.04.05, John E. Davis wrote:
> G. Milde <g.milde@xxxxxx> wrote:
> >#if (_slang_version > 20000)
> >message("SLang 2");
> >#else
> >message("Slang 1");
> >#endif
> 
> If you were able to preparse this, then there must have already been
> something on the stack because the preparsed files do not support these
> constructs.  

True, preparsing the above code takes 1 item from the stack.

I also wondered, whether the preparsed file takes something off the stack
instead of inserting, but could not proove it.

Evaluation the preparsed file was initiated via autoload, the autoloaded
function subsequently failed with a wrong argument type. 
Could it be that the evaluation occures after the pushing of function
arguments on stack? When will the _NARGS special variable be determined?


> The reason is that during preparsing, the expression
> (_slang_version>20000) does not get evaluated, leaving nothing for #if
> to test.  As a result, a syntax error should have been generated.

No syntax error (with S-Lang Version: 1.4.9) but an Stack Underflow if
there is nothing on the stack.

As I usually preparse all files in my local libray in a loop, this stayed
undetected.

	foreach (list_slang_files(dir))
	  {
	     file = ();
	     byte_compile_file(file, 0);
	  }


> I will have to think more about whether or not "#if (expr)" should get
> evaluated during this stage (naively, yes).  Otherwise a more
> informative error message about the use of such constructs would be
> better. 

Definitively (it took me 2 days to find out the reason of failure).

 
> If the behavior is changed for slang 2, that would not help you in
> this case because you want this to also work with slang 1.  I would use
> this test for slang2:
> 
>    #ifexists _slang_utf8_ok
>      <slang-2 code>
>    #else
>      <slang-1 code>
>    #endif

I'll go for this. Thank you.


What would be your replacement suggestion for

  #if (_jed_version < 9916)

?

Günter

-- 
G.Milde web.de

--------------------------
To unsubscribe send email to <jed-users-request@xxxxxxxxxxx> with
the word "unsubscribe" in the message body.
Need help? Email <jed-users-owner@xxxxxxxxxxx>.


[2005 date index] [2005 thread index]
[Thread Prev] [Thread Next]      [Date Prev] [Date Next]