IRC channel logs

2013-06-06.log

back to list of logs

<ckoch786_>What is the proper way to wait for a command to finish executing?
<ckoch786_>What is the proper way to wait for a non-returning function to finish executing?
<ckoch786_>the function does not return a value
<nalaginrut>morning guilers~
<nalaginrut>ckoch786: actually, non-return will return *unspecified*, but it seems implementation defined
<nalaginrut>is there anyway to count how much bytes an object in Guile occupied?
***fangism is now known as fangism-gonehome
<lloda>is this a bug?
<lloda>scheme@(guile-user)> (let ((a #(0 0 0))) (array-map! a (lambda (x) (values x x)) #(1 2 3)) a)
<lloda>$1 = #(#<values (1 1)> #<values (2 2)> #<values (3 3)>)
<lloda>
<nalaginrut>I think it's the similar bug which mark_weaver have fixed for map
<nalaginrut>but seems not for array-map
<lloda>hmm, replace above #(0 0 0) by (make-vector 3 0), but the issue stands.
<lloda>(too easy to make this mistake).
<lloda>do you know when that bug fix happened?
<taylanub>lloda: I don't understand why that's a bug ?
<lloda>'because' (map (lambda (x) (values x x)) '(1 2 3)) -> '(1 2 3)
<taylanub>Oh ...
<taylanub>I do find it somewhat weird that we have a concrete type of object for multiple-values; I thought multiple-values is something abstract that would only be reified via (call-with-values blah list) or such. Hrm, is that indeed the essence of the bug, or are there places where a multiple-values object is valid ?
<taylanub>(Other than that, I understand that if array-map! is specified such that it expects one value from its procedure argument, it should of course obey that specification and ignore other values (or raise an error).)
<lloda>Generally I agree that #<values ...> stuff shouldn't be visible, but I also find weird that (define k (if #f #f)) isn't an error...
<nalaginrut>lloda: it occurred for (map (lambda (x) (values x x)) (iota 2))
<nalaginrut>but fixed now
<nalaginrut>seems you found a but in array-map
<nalaginrut>s/but/gub
<nalaginrut>bug
<lloda>nalaginrut: but do you know when the bugfix happened for map? like commit/ml reference
<lloda>or I'll just wait for mark_weaver
<nalaginrut> http://debbugs.gnu.org/cgi/bugreport.cgi?bug=13966
<nalaginrut>oops, seems no this
<nalaginrut>lloda: http://savannah.gnu.org/bugs/?31445 it's been a while
<nalaginrut>lloda: and ludo fixed it, sorry for the confuse, bad memory ;-P
<lloda>the bug wasn't closed, but the problem went away when map was moved to Scheme
<lloda>it seems that the bug would be everywhere that scm_call_n is used if the result isn't checked for values objects
<nalaginrut>hmm
<rixed>Hi! shouldn't "(let ((x 1)) #(x))" return #(1) instead of #(x)? according to 6.7.3.1 it seams vectors are not supposed to be quoted by default (if that mean anything)
<lloda>'have to be quoted' != 'are not quoted', this can be read as '#(1) is an error'. Guile doesn't behave like that for sure.
<lloda>that line comes from 6.3.6 in R5RS.
<lloda>However R7RS says 'Vector constants are self-evaluating, so they do not need
<lloda>to be quoted in programs' ---this is how Guile has always behaved.
<lloda>
<lloda>The manual should be amended.
<lloda>You can do `#(,x) -> #(1). Pity it doesn't work with array read syntax...
<rixed>lloda: this is what I ended up doing, but I found this somewhat strange.
<rixed>lloda: thx for the confirmation, though.
<civodul>Hello Guilers!
<janneke>Heya!
<civodul>i'm looking for a volunteer to implement proxy support for the HTTP client
<civodul>anyone here? :-)
<davexunit>I'm here, but I don't have the background to do such a thing.
<civodul>perhaps there's code to steal from http://bugs.call-cc.org/ticket/403
<davexunit>I'm currently focusing my efforts on adding to figl :)
<civodul>ah, nice :-)
<janneke>ah, more users of guile http stuff /me likes
<taylanub>I might see if I have time in the next few days, but I don't want to promise anything.
*janneke was looking for an openid implementation in guile just yesterday...
<civodul>ok :-)
<davexunit>so people seem to like those web-page REPLs for trying out languages. project idea: make one for guile.
***sneek_ is now known as sneek
<civodul>+1
<davexunit>We could use artanis as the web framework, and then the majority of the work would be client-side javascript.
***sethalve_ is now known as sethalves
***janneke1 is now known as janneke
***fangism-gonehome is now known as fangism
<shanecelis>hey guilers
<davexunit>hey!
<shanecelis>Just did a post on Emacsy. Submitted it to reddit. Upvotes appreciated: http://www.reddit.com/r/programming/comments/1fst78/gsoc_2013_emacsy/
<davexunit>upvoting the fuck out of this
<shanecelis>davexunit: thanks!
<davexunit>and by that I mean 1 upvote.
<shanecelis>lol
<shanecelis>reddit always scares me. I try to submit it and forget it because the comments can be so caustic.
<davexunit>especially if you are working on things that are in any way GNU related.
<davexunit>there's a lot of GNU bashing in the "cool" programming discussion sites
<davexunit>like reddit or hacker news
<davexunit>and slashdot
<shanecelis>yeah, HN is probably worse regarding GNU and the GPL. Everybody there seems like they're just trying to get rich.
<davexunit>well yeah, every other post is about startups or web applications.
<davexunit>I sort of want to write a blog post rant about it and get this out of my system.
<shanecelis>blogging does seem like a good way or exorcising internal demons. :)
<davexunit>I guess I expected higher quality out of a site called "hacker news"
<davexunit>very few of the submissions are about real hacking.
<davexunit>why not call it "macbook pro ruby web developer news" ?
<shanecelis>yeah, it's more like disruptive business entrepeneurial CEO wannabe news.
<davexunit>and I say this as someone that writes ruby for a living.
<davexunit>(regretably on a mac)
<taylanub>davexunit: Haha, just today in #iphonedev there was bashind of GNU wrt. coding style and the GPL. (The latter is unsurprising since it's an Apple place, the former I'm guessing they have a point in but are possibly exaggerating.)
<taylanub>bashing*
<davexunit>people *love* to bash GNU coding style.
<shanecelis>I'm bashing HN but it's still one of the four sites I visit everyday.
<davexunit>those people can come talk to me when their programs have been in use by millions of people for 20 years.
<davexunit>shanecelis: same.
<taylanub>(Well they claimed to mean aspects of style that are "objectively" bad; I didn't inquire further.)
<shanecelis>When I first tried to do Emacsy as a kickstarter project, someone misread the license as GPL instead of LGPL, and they went apoplectic on HN. It gives me some satisfaction to think it'll be released as GPL now (maybe dual-license, we'll see).
<davexunit>what happened?
<shanecelis>I mean, just some guy started freakin' out that he thought it was GPL'd. There some bandwagoning and then some people kindly corrected him.
<shanecelis>But yeah, the love the BSD and MIT license makes total sense for the HN entrepreneurial crowd.
<davexunit>they sure do love those licenses.
<davexunit>"Hey HN, I used these permissively licensed tools to create this proprietary web service!"
<shanecelis>"YAY! I hope you get a million dollars funding. BTW Your site's accent should be blue instead of green; I've done A B testing. You should hire me."
<davexunit>hahahaha
<shanecelis>I saw this funny tweet today: @steveklabnik "Startups: other people's money (VC) with other people's servers (the cloud) with other people's code (OSS)."
<davexunit>that's great.
<add^_>lol
<mark_weaver>civodul: I'm investigating what would be needed to add proxy support to the Guile HTTP client. Looks like it should be fairly straightforward.
<mark_weaver>davexunit: The main difficulty for making a Guile REPL for either IRC or a web page is sandboxing it.
<davexunit>mark_weaver: yes indeed
<mark_weaver>but I agree it would be very nice to have.
<davexunit>just an idea for someone :)
<mark_weaver>rixed_: #(x) is the same as '#(x). You wouldn't expect '(x) to return a list containing the value of variable 'x', would you?
<mark_weaver>lloda: that array-map! thing is indeed a bug
<mark_weaver>taylanub: the concrete object type for multi-valued returns is needed for the C interface. In the VM, multi-valued returns are done without creating such objects.
<mark_weaver>nalaginrut: counting the size of objects in bytes is a thorny business, because what do you do about parts of an object that could be shared between multiple objects? Out of curiosity, what would you use such a mechanism for?
<davexunit>mark_weaver is dropping all sorts of knowledge on all of us right now.
<mark_weaver>lloda: the example expression you gave modifies a literal object, which is technically prohibited and eventually we will raise errors in such cases: (let ((a #(0 0 0))) (array-map! a (lambda (x) (values x x)) #(1 2 3)) a)
<mark_weaver>lloda: it's a very bad idea to modify literals, because you are essentially changing the copy of the source code that's loaded into the system.
<shanecelis>lloda: I did that once too, and it drove me crazy trying to figure out what was going on.
<mark_weaver>lloda: for example, consider the following procedure: (define (foo i) (let ((a #(0 0 0))) (vector-set! a i 1) a))
<mark_weaver>lloda: then you'll see the following results: (foo 0) => #(1 0 0)
<mark_weaver>lloda: (foo 1) => #(1 1 0)
<mark_weaver>lloda: (foo 2) => #(1 1 1)
<mark_weaver>and then if you look at the code with ",x foo", you'll see that the literal #(0 0 0) has actually been changed to #(1 1 1)
<mark_weaver>detecting these errors is on my TODO list :)
***linas__ is now known as linas
<mark_weaver>wingo: I'm surprised to find that 'write-request-line' is not percent-encoding the URI components. Is the encoding happening somewhere else?
<mark_weaver>is it assumed that the components of a URI record are already encoded?
<mark_weaver>ah, I guess so. apologies for the noise; showing my ignorance of this code.
<wingo>np :)
*wingo currently live on the internet radio
<wingo>they are playing an ad now, but http://nodeup.com/ fwiw
<mark_weaver>cool! :)
<shanecelis>davexunit: Ha, finally found you on twitter. [follow]
<davexunit>shanecelis: are you on statusnet or diaspora?
<shanecelis>davexunit: nope.
<davexunit>also I will return the follow
<davexunit>I'm looking for diaspora friends. going to see how well pump.io takes off as well.
<shanecelis>I'll have to check them out.
<davexunit>they are the free-as-in-freedom social networks
<davexunit>you can set them up to cross-post to twitter/facebook if you want
<shanecelis>davexunit: Ou, that's good.
<davexunit>wingo: where do the section numbers come from in the figl source file comments?
<wingo>the gl spec
<davexunit>I must be looking at the wrong document. the opengl site links me to amazon a couple of times and then to the api docs. guess I missed the spec.
<davexunit>thanks.
<davexunit>what version of the spec?
<davexunit>wingo: trying to prepare a patch for texture-related functions.
<mark_weaver>remember wingo is live on the radio right now.
<davexunit>oh he is?
<davexunit>was not aware.
<mark_weaver>he said so in his last few messages here.
<davexunit>oh you're right. -__-
<davexunit>wasn't paying attention.
<mark_weaver>:)
<civodul>sneek: later tell mark_weaver excellent, looking forward to applying the patch ;-)
<sneek>Got it.
<civodul>howdy wingo
<davexunit>is it possible to register a callback for when a record type object is GCd?
<davexunit>when dealing with smobs in C it's possible to do some cleanup
<taylanub>davexunit: I can't envision how that could be useful; could you explain your use-case ?
<davexunit>taylanub: the example I came up with is for an OpenGL texture.
<davexunit>there is a function for generating a texture that returns a texture id. there's another function for deleting a texture that takes a texture id.
<davexunit>it would be nice to write a wrapper around this so that we didn't have to manually delete the texture.
<davexunit>using the C api, I could make a smob and register a function that did the appropriate call to glDeleteTextures.
<davexunit>it would be cool to have the same power when using the FFI
<taylanub>Hrm, I see, while a smob is the typical way to couple a manually-memory-managed C API to Guile's GC, this could be done on the Scheme level just as well by coupling an object in the C API to any Scheme object.
<davexunit>taylanub: how so? keep in mind that we're just using Guile's FFI here. no smobs or anything.
<mark_weaver>davexunit: Although I've never used them, I suspect that "Guardians" are what you want.
<sneek>Welcome back mark_weaver, you have 1 message.
<sneek>mark_weaver, civodul says: excellent, looking forward to applying the patch ;-)
<mark_weaver>see 'make-guardian' in the manual
<davexunit>mark_weaver: thank you!
<mark_weaver>welcome :)
<taylanub>davexunit: I mean, I agree now that there should be a way to arrange for a C destructor to be called upon the garbage-collection of a Scheme object, such that objects from C APIs can be coupled to Scheme APIs without having to define new smob types.
<taylanub>(Previously I simply couldn't envision this possibile alternative to defining new smob types.)
<taylanub>possible*
<davexunit>the guardian doc is a little bit confusing. going to re-read this a few times.
<davexunit>I don't see how I'd use this to register a callback before the object was GC'd
<mark_weaver>you have to poll it periodically
<mark_weaver>actually, as I recall you can register a procedure to be called after gc happens.
<mark_weaver>hmm, not sure if we have an API for that.
<davexunit>after gc? I'd like a before-gc callback so I could do some cleanup beforehand.
<mark_weaver>well, after GC is when it would be discovered that the protected object is no longer referenced from anywhere.
<davexunit>ohhh okay.
<davexunit>would this be on a per-object basis?
<taylanub>davexunit: At arbitrary points in your code, you empty the guardian's set of protected objects, applying the clean-up to each while doing so. (At certain points you could also limit the number of objects you clean up so as not to hang your program for too long, but at certain points you should probably clear it entirely or you might have memory leaks.)
<mark_weaver>I admit that we could use a nicer API for this, but the way it works is as follows: first do (define my-guardian (make-guardian))
<mark_weaver>and then call (my-guardian <object>) to protect an object.
<davexunit>psuedo-code: (register-after-gc-callback object my-cleanup-proc)
<mark_weaver>periodically call (my-guardian), which checks for registered objects that are no longer referenced, and ready to free.
<davexunit>that <object> notation, so we guard a whole type of object?
<mark_weaver>(my-guardian) will either return #f or an object that's ready to be freed.
<davexunit>okay, and I can do this check with an after-gc callback somehow?
<taylanub>davexunit: You could implement that `register-after-gc-callback' in terms of a guardian, but you'll still have to trigger cleanups manually.
<mark_weaver>no. if you have an object to protect that's bound to variable 'foo', then call (my-guardian foo)
<mark_weaver>then, when 'foo' is no longer referenced anywhere, (my-guardian) will return foo.
<davexunit>taylanub: it's the triggering cleanups manually that I'm trying to avoid.
<mark_weaver>then you can do your cleanup action, and it will really be freed on the next GC.
<taylanub>Perhaps the clean-up could be hooked to something that's known to be executed periodically, like after each garbage-collection that ran for any other reason ...
<mark_weaver>ideally, one would register an "after GC" hook that calls (my-guardian) repeatedly until it returns #f.
<mark_weaver>civodul or wingo might know a better way.
<taylanub>(I guess that could still *theoretically* leak memory, if your code happens to have such a form that it never triggers garbage-collection.)
<taylanub>(That's probably pretty much impossible ?)
<davexunit>would it be somewhat easy to add something like the pseudocode I posted if what I want doesn't exist?
<davexunit>a Scheme equivalent of the scm_gc_mark function.
<mark_weaver>huh? scm_gc_mark? I don't see the relevance of that function to this discussion.
<davexunit>oh sorry, wrong function.
<davexunit>scm_set_smob_free
<mark_weaver>internally we have something called 'scm_i_set_finalizer'
<davexunit>I have to leave now. I'll do some more doc searching and perhaps we can continue this conversation later.
<mark_weaver>I guess that's what we'd like to have available in the Scheme API.
<mark_weaver>okay, ttyl!
<davexunit>thanks for all the help
<taylanub>Ha: (info "(guile) GC Hooks")
<taylanub>Shoot, ey's gone!
<taylanub>Oh wait, that only has `after-gc-hook'.
<mark_weaver>taylanub: good find :)
<civodul>but if the texture lives in the GPU, you don't want it to be "GC'd"
<civodul>wild guess
<mark_weaver>after-gc-hook is what's needed though, I think.
<taylanub>For the guardian-based implementation it would suffice I guess.
<taylanub>Not for a more precise one though, right ?
<mark_weaver>a more precise one?
<mark_weaver>GC is presumably when it becomes known that guarded objects are ready to be finalized.
<taylanub>If the guarded objects weren't in fact guarded (but only had a before-gc hook on them), then the GC might run more frequently .. but that's still ont precise anyway so I guess it doesn't matter much.
<taylanub>s/ont/not/
<taylanub>(I forgot for a moment that our GC is simply not precise. :D)
<mark_weaver>a before-gc is not associated with a particular object. it's global. it's called before GC happens.
<mark_weaver>I wonder what this is about, in 'uri->string' (web uri): (if (string-index host #\\:) (string-append "[" host "]") host)
<civodul>IPv6?
<mark_weaver>ah, yes, thanks :)
<taylanub>Global before-gc works too; what I mean is that in the guardians/after-gc implementation, GC will be called less frequently because the guarded objects don't count as collectable; only after GC runs for some other reason they are unguarded and cleaned on another, subsequent GC.
<mark_weaver>when talking to an HTTP proxy, the main difference is that you have to send the entire URI in the request, not just the path. pity that I can't use 'uri->string' for this, but I can't because we mustn't send the fragment (which is not part of a URI, but only a URI-reference).
<mark_weaver>I really need to take another look at wigs' URI patches.
<taylanub>(It's late evening, my wording has gotten sub-optimal. :) Good night!)
<mark_weaver>good night!
<mark_weaver>civodul: deciding how to change the API to support proxying is the hardest part here.
<civodul>ah, yes
<civodul>i would start with something Guix-specific, i think
<civodul>and then backport it
<civodul>so the first iteration would have to be relatively separate
<civodul>dunno
<mark_weaver>biab..
<mark_weaver>so the issue is that if we're talking to a proxy, then 'write-request-line' has to send an absolute URI, instead of just a path.
<mark_weaver>so there's plumbing that has to be done.
<mark_weaver>which is not too bad, but I'm a bit uncertain of how to change the API of procedures like 'http-get' that can be passed an existing port.
<mark_weaver>if a user passes the port, then he must also pass the information of whether we're talking to a proxy.
<mark_weaver>actually, there's a simpler solution which if worth considering.
<mark_weaver>http 1.1 requires that http servers MUST accept absolute URIs in the request line, even if it's not a proxy.
<mark_weaver>so we could simply always send an absolute URI, and then avoid having to keep track of whether we're talking to a proxy.
<mark_weaver>in fact RFC 2616 suggests that in a future version of HTTP, absolute URIs will always be sent.
<mark_weaver>but the current practice is that clients usually only send an absolute URI when talking to a proxy, presumably to ease potential compatibility problems.
<mark_weaver>well, I'll think some more on the issues and post something to the ML.
<civodul>hmm, ok
<civodul>not as simple as i would have thought, it seems
<mark_weaver>the simplest solution, if we always send absolute URIs, could be as simple as monkey-patching 'open-socket-for-uri' and 'write-request-line'
<mark_weaver>but it's possible that some non-compliant HTTP servers might fail to accept an absolute URI.
<mark_weaver>a slightly more complex approach could perhaps work by patching the same two procedures, but using an object-property on the port to keep track of whether we're talking to a proxy.
<civodul>oh, i like this :-)
<mark_weaver>solving the problem for Guix will indeed be easier than coming up with a sane API for Guile.
<civodul>sounds like there are opportunities for monkey patching
<civodul>yeah
<mark_weaver>okay, I'll start by solving the problem for Guix, and go from there.
<civodul>great!