IRC channel logs

2016-04-25.log

back to list of logs

<shanemikel>ughhh.. I guess I'm gonna need to define my own error type so I can write a catchall to escape the exception mechanism and get something like an Either GError SCM in haskell
<shanemikel>I wonder why there isn't a c_catch function with the handler typed to return void* (like the with_continuation one)
<shanemikel>with continuation barrier that is
<shanemikel>to be more precise, Of course I'm gonna have to define my own error type, but I would rather not define my own error SCM type
<shanemikel>any thoughts whatsoever about the exception mechanism, and the most general approach that will allow me to handle all uncaught exceptions nicely with all the behavioral variants?
<shanemikel>what's the difference between with_throw_handler and catch_with_pre_unwind_handler?
<sapienTech>hi all, trying to install slib-3a3 for guile-2.0.9 following the guide in the guile manual but having some issues.
<sapienTech>After (require (ice-9 slib)) and (require 'new-catalog), I get: Unbound variable: list->uniform-array after trying (require 'primes)
<sapienTech>the manual suggests i modify ice-9/slib.scm to add define-public for the offending variable, but I can't seem to get that to work
<ijp>out of curiousity, what are you using slib for?
<sapienTech>I am interested in using the prime? procedure
<sapienTech>looking through the libraries I have, i can't even find a list->uniform-array procedure. Is this a deprecated procedure?
<ijp>it doesn't sound familiar
<ijp>there are a bunch of procedures for converting to specific kinds of uniform array, but none that are general afaik
<ijp>and it wouldn't be removed if it was only deprecated
<ijp>maybe it matches one of list->array or list->typed-array
<sapienTech>/usr/local/lib/slib/guile-2.init:625:8: In procedure module-lookup: Unbound variable: list->uniform-array is where I'm getting the error
<sapienTech>yeah im going around now to see if it matches those
<rain1>where is slib maybe we could just take the prime code out
<rain1>it seems to be ancient and broken
<wingo>paroneayea: why run-delay instead of (sleep) ?
<wingo>for me i think i prefer the abstraction to be threads; dunno tho :)
<civodul>with (sleep n) = (abort-to-prompt scheduler-prompt (run-request n)) maybe?
<lloda>sneek: later tell daviid thx
<sneek>Got it.
<lloda>sapienTech: it should be list->typed-array. list->uniform-array was redundant and was removed in 2009 according to git
<civodul>guile-gnutls to be dropped from Debian: http://lists.gnutls.org/pipermail/gnutls-devel/2016-April/007969.html
<wingo>civodul: yeah
<wingo>regarding sleep, yeah
<paroneayea>wingo: well I'm not actually doing multiple threads, which is why not sleep!
<paroneayea>sleep is blocking on a single threaded application; telling the scheduler to execute this in n seconds isn't, right?
<paroneayea>wingo: "why not threads" is basically because I don't want to deal with locking issues, and also I'm miming the systems I know :)
<wingo>well, think "goroutines" if you like
<paroneayea>wingo: admittedly I don't know much about goroutines!
<wingo>i mean a thread is an abstract thing, it might not execute in parallel with other things like pthreads
<wingo>like you can have one thread per client on a web server
<wingo>but each thread is just a delimited continuation
<wingo>that suspends whenever it needs more information from the other party, or the other party hasn't read the information that it sent, etc
<wingo>like you should be able to write a "thread" in 8sync that just does (let lp () (sleep 10) (lp))
<wingo>for a suitable definition of sleep
<wingo>one that suspends back to the scheduler and arranges to reinstantiate the thread in 10 seconds
<paroneayea>wingo: ah via message passing?
<davexunit>this is how sly's coroutines work
<davexunit>instead of 'sleep' it's called 'wait'
<paroneayea>davexunit: sly's coroutines run in multiple threads?
<davexunit>which is implemented on top of a generic 'yield' procedure which aborts to the coroutine prompt
<davexunit>paroneayea: no
<davexunit>I don't think "thread" in this context means "pthread"
<paroneayea>ok
<paroneayea>so, I could implement a "wait" routine but
<paroneayea>that's basically what's happening
<paroneayea>if I'm reading the above right
<paroneayea>suspending on need of information for the other party
<paroneayea>*with the exception* of time deltas
<paroneayea>but anything doing (8sync (foo))
<davexunit>how do you specify that you want to wait 10 seconds in 8sync?
<paroneayea>davexunit: there's a time delta object made and attached to the run-request
<paroneayea>the run-request is the thing that jumps back to the prompt
<davexunit>okay
<davexunit>so seems like you can already do what wingo wants, then.
<paroneayea>so for most operations, I think 8sync works like the "kind of" threads you're talking about above
<davexunit>albeit more verbose
<paroneayea>but since select / poll / etc already have a "wait for this long" thing
<paroneayea>and we already use that
<paroneayea>I use that system call's facility
<paroneayea>for time stuff specifically.
<paroneayea>there's a calculation done of "how long do we need to wait for the next thing on the agenda's queue"
<paroneayea>but
<paroneayea>we could provide a (wait 10)
<paroneayea>that's just sugar for the above anyway
<davexunit>in sly, there is a parameter for the current agenda. does 8sync also do this?
<paroneayea>davexunit: yes
<davexunit>cool
<paroneayea>there's a parameter for the prompt
<paroneayea>it's the only "global variable"'ish thing in there
<paroneayea>but since it's a parameter, I think it's not so bad
<paroneayea>having to pass around the prompt tag seems like it would make code ugly
<davexunit>agreed
<davexunit>this is the perfect use-case for dynamically scoped variables.
<paroneayea>there's only one mutate'y thing in 8sync core iirc too, which is that we use (ice-9 q)
<paroneayea>but... I've left things in such a way that I could explore replacing it with a more functional queue like maybe from ijp's pfds library
<paroneayea>and fold across the queue instead
<davexunit>scheduling is an inherently imperative task
<paroneayea>davexunit: I dunno, if you fold across an immutable queue, does it have to be?
<wingo>hoo, i hate (ice-9 q) :P
<davexunit>I mean, you could do that if it makes the implementation better.
<paroneayea>I think the only reason to do it though is if we could get elm-style "replayability", but that would require that a user really really only do functional programming on top of it, and that we record the inputs from ports in a way that can be replayed
<davexunit>but we're still dealing with stateful things, there's no way around it. there's a core kernel of imperative code that needs to be there.
<paroneayea>wingo: heh yeah? why? :)
<paroneayea>wingo: is it super innefficient or something?
<wingo>it's just uggs
<paroneayea>it looks like mostly the queue implementation from sicp
<paroneayea>so, if someone really does want multiple cores churning away at things to keep things more efficient
<paroneayea>I'm hoping by the end of the week to have my actor model subsystem working to the point where you can distribute tasks across processes
<davexunit>paroneayea: I intend to achieve replayability at a higher layer than the scheduler in Sly.
<paroneayea>davexunit: that's interesting
<davexunit>it's really just consing a list of history
<paroneayea>davexunit: I guess it could be done there
<davexunit>and associating each objects with a time stamp
<paroneayea>ACTION nods
<davexunit>that's roughly what Elm does, too.
<paroneayea>I guess I won't worry too much about using a mutable queue in 8sync then :)
<davexunit>I wouldn't until it becomes apparent what a win would be.
<davexunit>I implemented a functional queue awhile back
<davexunit>following along with some paper.
<paroneayea>I wonder if it was Tyng-Ruey Chuang's paper
<paroneayea>he's one of the CC affiliates
<paroneayea>but I found a paper about functional queues and I was like "is this you?"
<paroneayea>and it totally was!
<davexunit>ah, it was Okasaki. should've known.
<paroneayea>oh, ha
<paroneayea>I have the PFDS book, but it's over my head
<paroneayea>I don't grok ML syntax yet
<davexunit> http://www.cs.cmu.edu/~rwh/theses/okasaki.pdf
<davexunit>wait, no.
<davexunit>darn.
<davexunit>that's the pfds thing
<davexunit>there's a paper that is just about queues
<davexunit> http://www.westpoint.edu/eecs/SiteAssets/SitePages/Faculty%20Publication%20Documents/Okasaki/jfp95queue.pdf
<davexunit>this
<davexunit>uses streams like in srfi-41
<civodul>davexunit: i don't think scheduling is "inherently imperative", it's just about shuffling queues around no :-)
<davexunit>civodul: there's some amount of state to maintain
<davexunit>sure, persistent queues could be used
<ArneBab>paroneayea: you tutorial is fun to read. It might be stronger, if it included parts of the output to show what a reader can expect to see.
<paroneayea>ArneBab: yeah you're right
<civodul>davexunit: right, but the scheduler is a function that takes a state and an event and returns a state :-)
<davexunit>;)
<random_nick>I remember reading some article about how C is a purely functional language
<random_nick>it had some really far-fetched assumptions
<davexunit>I hate those type of articles
<random_nick>this one was parody afaik
<random_nick>no one who knows what C is and what purely functional programming is can claim that seriously
<random_nick>found it
<random_nick> http://conal.net/blog/posts/the-c-language-is-purely-functional
<df_>haha
<davexunit>random_nick: was it parody?
<davexunit>conal elliot's writing rubs me the wrong way
<davexunit>he coined the term "functional reactive programming"
<davexunit>and defined it very narrowly
<davexunit>and then got upset when other people started making different takes on it and calling it FRP
<df_>I think it makes a reasonable point, eg the state monad is basically recreating imperative programming in a more formal way
<davexunit>df_: sure, that is a fair point.
<davexunit>I use monads all the time to create a functional layer on top of an imperative system
<davexunit>my favorite is my OpenGL rendering monad.
<paroneayea>augh
<paroneayea>guile why do you think I've redefined this struct when I haven't
<paroneayea>* Original key 'wrong-type-arg and arguments: (#f "Wrong type to apply: ~S" (#<syntax-transformer mes
<paroneayea>sage-to>) (#<syntax-transformer message-to>)) *
<paroneayea>weirdly this never happens during live coding
<paroneayea>which is why I missed... whatever's happening.
<paroneayea>ACTION goes afk
<rekado>I want to monkey-patch a private procedure in (web http). It uses a macro defined in (web http). To redefine the procedure with "module-set!" I'd also need to access the macro.
<rekado>is there a way to access a macro with the (@@ (web http) ...) syntax?
<rekado>or is there something comparable I could use?
<random_nick>is there a recommended way for getting values out of a closure's environment without calling it?
<davexunit>you can't reach into a proceure's environment.
<davexunit>a closure is an implementation technique.
<davexunit>not all procedures are closures.
<random_nick>yeah but those who explicitly reference these variables?
<davexunit>I don't understand the question
<ArneBab>random_nick: in short: no
<random_nick>okay
<mark_weaver>random_nick: local variables can only be accessed from within their lexical scope
<mark_weaver>and the compiler makes use of this, e.g. if a variable is never 'set!' from within the scope then it can assume that its value never changes, and it can even be optimized out completely
<mark_weaver>however, what *is* possible is to create one or more procedures from within the lexical scope, and make those procedures available to the outside somehow
<mark_weaver>e.g. (cons (lambda () VARIABLE) (lambda (value) (set! VARIABLE value)))
<mark_weaver>guile comes with a macro called 'the-environment', which captures a lexical environment, and it works by automatically creating procedures like this
<mark_weaver>and you can pass the result of 'the-environment' to 'local-eval' to evaluate arbitrary expressions within that environment
<mark_weaver>but beware the using 'the-environment' within a lexical environment will greatly hinder what our optimizing compiler is able to do with that code
<mark_weaver>because it must assume that the variables might be mutated at any time from the outside
<mark_weaver>random_nick: ^^
<random_nick>thanks
<random_nick>forgot about the-environment and that upvalues can be more than one up
<wingo>meep
<civodul>plop
<stis>hej guilers!
<wingo>ACTION plugging ahead at port refactor branch; done soon
<wingo>though threadsafety without types is pretty hard :/
<wingo>almost anything in a critical section can throw; you end up needing dynwinds all the time if you provide serialization guarantees that cover more than a single mutable field
<wingo>terrible
<civodul>wingo: but dynwinds are cheaper in 2.2, no?