~technomancy/fennel#81: 
if returns zero values in case false branch is not specified

>> (select "#" (if false 42))
0

I believe this affects when, match, and possibly some other constructs built on top of if. Instead it should return nil implicitly.

Status
RESOLVED FIXED
Submitter
~andreyorst
Assigned to
No-one
Submitted
2 months ago
Updated
a month ago
Labels
1.0 enhancement

~technomancy a month ago

We talked this thru on chat and I believe the conclusion we came to is that we can't avoid the fact that Lua allows you to return zero values, but it should be avoided by default, and if people really want zero values they can include an else branch with (values) in it. So we would rather have the default else branch be nil.

~technomancy a month ago

I have this implemented in the implicit-else-nil branch: https://git.sr.ht/~technomancy/fennel/commit/176c90b0695a5e3880b2fc856d6a445119a7e7ee

~andreyorst a month ago

Did a bit of testing, everything that uses if internally seems to work fine

~technomancy REPORTED FIXED a month ago

Thanks; went ahead and merged it. Will try to get some more eyes on this change as it's rather large.

Register here or Log in to comment, or comment via email.