I had trouble with ``do`` a long time ago as well, in the context of the 
HttpServer package, where I thought it was some clever macro-thing 
particular to that package.
In fact, when teaching HttpServer.jl in a class, I avoiding the do block 
because I didn't want to confuse 
anyone: 
https://github.com/IainNZ/ORSoftwareTools2014/blob/master/ProjectPart1/nameservice.jl#L16-L34

I'm not saying to get rid of it, just a +1 to the way it can trick people. 
Python's ``with`` didn't confuse me at all, FWIW.

Cheers,
Iain

On Monday, April 28, 2014 1:41:43 PM UTC-4, ggggg wrote:
>
> One difficulty I had with `do` is that its really hard to find in the docs 
> if you don't have any idea what it is.  Try googling it or searching for it 
> in the docs, do is just really a common word so there is a lot of 
> interference. Then it sort of looks like an if or while statement, so I 
> tried looking in Control Flow, but its not there.
>
> Also I think open is a particularly confusing (but also useful) example of 
> the do block syntax, since the specific method of open that is called is 
> fairly different from most of the other open methods.  Most methods return 
> a file handle, and leave the file open, while this particular method opens 
> and closes the file. So it's sort of a double whammy of potential confusion.
>

Reply via email to