lua-users home
lua-l archive

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


Hi, Rici

I guess you are Lua certified, aren't you :P
just a joke! :)

>c:setopt("writefunction", function...
>c:setopt("writedata", ..

>local c = curl.new():setopt("url", url)
>                       :setopt("connecttimeout", 15)

I got your point, also what do you think about
c["writefunction"]=function..
or the sugar c.writefunction=function..

and guess how could become if c.__newindex returns self!

(((c.writefunction=function...).writedata=...).url=...):perform()

Bad idea : ), also I'm not sure if possible

Anyway, your remark is a good point.

>Actually, though, there is a good argument for a different type
>of binding for the writefunction/writedata options. A more
>Lua-like binding would be similar to LuaLDAP, where the perform
>function returns a generator (a "future", if you prefer), and
>the caller can do whatever they want with the resulting strings.

>   for chunk in c:perform() do
>     table.insert(chunks, chunk)
>   end  


Excellent!
But you know that always when there is a data stream there is a 
problem "who is pushing, who is pulling".
I mean the function returned by c:perform() will "pull" data from curl. But actually curl "push" the data through a callback.

Anyway, this is another good point to think about

> c:perform();
> c:close();
>I presume the garbage collector would take care of closing?
sure

>Thanks, again. Looks like it will be very useful.

I thanks for the good remarks.


_____________________________________________________________
Get your free email at http://www.crazyland.com