~hayohayo

Recent activity

Re: Breaking out of the loop 1 year, 1 month ago

From Slava Lopata to ~technomancy/fennel

3, 2018, 8:27 PM by phil@hagelb.org <mailto:phil@hagelb.org>:

>> Interesting, thanks. Don't all current looping constructs are statements
though?.. (each), (for), (while).
> No, lisps don't have statements; these are simply expressions which
return nil.

What I am trying to say, currently (each), (for) and (while) loops
in Fennel - all are basically "statements", they are used for
side-effects. In this case value in the tail position becomes
less relevant, I guess.

Slava

Re: Breaking out of the loop 1 year, 1 month ago

From Slava Lopata to ~technomancy/fennel

Dec 3, 2018, 8:34 AM by phil@hagelb.org <mailto:phil@hagelb.org>:

> But if you just want this one function, I'd use this:
>
> (fn find-index [t v i]
>   (let [this (. t (or i 1))]
>     (if (= this v) (or i 1)
>       (= nil this) nil
>       (find-index t v (+ 1 (or i 1))))))

Yes, I see. This one is indeed very specific. Yet, I assume, even then
it may be less efficient than Lua's for with break/return?

> One nice thing about lisps is that their syntax is consistent. One of

Breaking out of the loop 1 year, 1 month ago

From to ~technomancy/fennel

Hi everyone,

I was reading documentation and stumbled upon a lack of early returns in Fennel: https://github.com/bakpakin/Fennel/blob/master/tutorial.md#gotchas. <https://github.com/bakpakin/Fennel/blob/master/tutorial.md#gotchas> Say, how does one look for an element in an array? I can think of doing this recursively and manually calling next() on table, but not sure if this is the preferred way.

Also, it looks like there had been a break special form before, but it was removed. What's the rationale of not having returns and breaks and what are the alternatives?

Thanks,
Slava