[Top][All Lists]

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

Re: if-let and when-let: parallel or sequential

From: Bozhidar Batsov
Subject: Re: if-let and when-let: parallel or sequential
Date: Mon, 11 Aug 2014 20:49:29 +0300

On August 11, 2014 at 17:42:20, Stefan Monnier (address@hidden) wrote:
> if-let and when-let don’t make much sense with more than one binding 
> form. 

Why do you think so? If they only work for a single binding, the 
benefit is really minor. It's only when you use several bindings that 
the benefit becomes more significant (the alternative being either 
a very deeply nested code, or separating the var's declarations from 
their initialization). 


Practically speaking, the most common case people run into is checking whether a single object is nil 

and binding it to some local if it’s not. Binding multiple locals in such a form reduces the clarity of the code because the 

semantics are not that clear anymore - should all the forms produce non-nil or should only the first form produce non-nil? Obviously 

people can (and should) read the documentation, but I’m a huge believer in intuitive APIs. That said, I’m fine with whatever 

behavior you decide upon, as I believe those functions are valuable additions regardless.

reply via email to

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