users-prolog
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Reading a file for lexing, one way to do it...


From: Sean Charles
Subject: Re: Reading a file for lexing, one way to do it...
Date: Tue, 23 Jul 2013 08:10:01 +0100

Hi Daniel,

Thanks for taking the time to write such a good reply…

> 
> Remark: your list is ended by a variable (reported as an underscore by the 
> top-level). This is totally OK (and often used to further add elements to the 
> end of the list). If it is not the wanted behavior (you want a proper list 
> ended by the empty list []), you have to replace the first lexread/2 clause 
> by:
> 
> lexread(In, []) :- at_end_of_stream(In), !.

I had to really look but then I saw you haste have "[]" instead of _.

Then a huge penny dropped as to where the "mysterious" empty variable at then 
end of the list came from! It made me laugh! When you see things clearly, 
sometimes it hurts your eyes. That's a beautiful answer and I thank you for 
your time to explain it.

That was an enlightenment moment because I have been plagued by the same issue 
in some other code I have been playing with and now I can go back and kick its 
butt into submission with FULL understanding which is all you can ever hope for.

Thanks!

:)
Sean.




reply via email to

[Prev in Thread] Current Thread [Next in Thread]