Hi Alex,

On 3. Sep, 2014, at 14:56, Alexander Burger <a...@software-lab.de> wrote:

> Hi Jon,
>> : (index 9 (list 1 2 (prinl 9) (prinl 'more) 9))
>> 9
>> more
>> -> 3
>> I see that the index function evaluates the entire lst before
>> searching for a match. Wouldn’t it be more efficient to evaluate the
>> elements of lst one by one, testing the result for a match, and only
>> proceed with evaluation of the next element if a match was not found? Is
>> there a specific reason why you didn’t implement it that way?
> What you describe here is call "lazy evaluation". While some languages
> support this, PicoLisp (like most other Lisps) doesn't.
> Think about what this would mean: The function 'list' must know somehow
> that it should stop, because some function up in the call history
> doesn't need the whole list.
> And even if it knew that, can it know that some side effects (like your
> 'prinl' above) may be omitted?
> The fundamental rule of Lisp function calls (a function recursively
> evaluates its arguments before it starts to run) is broken here.

Thanks! I think I see it more clearly now. What I observed in my example above 
was not caused by the 'index implementation, it was caused by the (PicoLisp) 
standard way of operation of the 'list function.

UNSUBSCRIBE: mailto:picolisp@software-lab.de?subject=Unsubscribe

Reply via email to