IRC channel logs

2016-08-24.log

back to list of logs

<davexunit>sapientech: macros are not procedures. apply calls a procedure with the given argument list.
<sapientech>davexunit: okay cool i was thinking along those lines, so i was suprised to see some code that was trying to do that...
<davexunit>'macro' doesn't match the pattern (macro param1 param2 ...)
<sapientech>davexunit: for testing purposes, lets say i wanted to feed a bunch of different macros the same inputs, any idea for the best way to do that?
<amz3`>ah there is a way to do that, let me find an example
<amz3`>sapientech: with def-macro?
<amz3`>I think it's not possible with define-macro, at least I am not aware, but if you define-sytax you can feed different forms the macro so that it match different syntax
<sapientech>amz3`: thanks for the info! and yes i am working with define-macro
<amz3`>here is an example using define-syntax https://github.com/amirouche/microKanren/blob/master/microKanren.scm#L87
<amz3`>the first case takes only one argument ((_ g) (Zzz g)), the second case takes several arguments
<amz3`>ntime overhead
<sapientech>amz3`: dope thanks :)
<amz3`>sorry my irc client dropped somekind of explanation, I think you got it
<amz3`>I made good progress today, I am happy!
<amz3`> /night
<rekado_>I'm trying to read from a bytevector port with (get-bytevector-n port 56), but the resulting bytevector is 59 bytes long.
<rekado_>is this normal?
<rekado_>argh, no, I think I'm just confused. Never mind!
<rekado_>phew, all is good.
<dsmith-work>Wednesday Greetings, Guilers
<amz3>héllo!
<OrangeShark>good day
<HotLava>Hi
<HotLava>What is a good way to get the output of a shell command in guile?
<HotLava>I tried (define ls2 (with-output-to-string (lambda () (system "ls")))), but it seems to just return an empty string?
<davexunit>HotLava: See section 7.2.10 in the manual
<davexunit>'system' doesn't do anything with i/o
<davexunit>'system' is for the purpose of running a shell command and getting its exit code
<davexunit>you want open-pipe or open-pipe* from (ice-9 popen)
<amz3>HotLava: what is the command you want to bind?
<amz3>HotLava: here is an example of calling html2text with text input from scheme and retrieving the output
<amz3> https://github.com/amirouche/Culturia/blob/master/src/text.scm#L16
<amz3>this is a bit more involving that just getting the output
<HotLava>davexunit, thanks a lot, i was hoping for a slightly higher level interface, but this will also work
<davexunit>feel free to write one :)
<HotLava>i doubt guile wants to have my half-baked hacks in its standard library ;)
<HotLava>amz3, i want to parse aptitude/dpkg output for some small script
<davexunit>ACTION just made FRP a whole lot nicer
<davexunit>(define-signal foo 1)
<davexunit>(define-signal bar 2)
<davexunit>(define-signal baz (+ foo bar))
<davexunit>baz
<davexunit>;; => 3
<davexunit>(define-signal foo 8)
<davexunit>baz
<davexunit>;; => 10
<davexunit>yay for the magic of macros
<davexunit>hmm, I have an interesting problem that is revealing how little I really know about macros.
<jbdatko>What does the '%' mean in front of some variables? Like, from the guile reference manual, the load-path vairable is `%load-path`.
<davexunit>jbdatko: it's just a naming convention. usually reserved for globals.
<jbdatko>ah, thanks
<davexunit>I see it used for constants
<davexunit>most of the time
<davexunit>I'm trying to write a macro that rewrites procedure application e.g. (+ 1 2 3) into some other form, but I would like it to play nice with other macros and it doesn't.
<davexunit>for example (quote 1 2 3) isn't a procedure application, so I'd like my macro to leave it alone.
<davexunit>guess I'll need an equivalent of quote/unquote
<paroneayea>soon I need to write a pubstrate client demo UI
<paroneayea>I guess I'll either try guile-ncurses or guile-gnome
<paroneayea>or write half implemented versions of both :)
<paroneayea>see, if we had guile-emacs, it would be easy to write an emacs mode leveraging the things I already have!
<amz3`>on my side I need to provide better machinery for wiredtiger multithread
<amz3`>multithread wiredtiger
<amz3`>it seems like I can't do it without breaking my current code :/
<amz3`>the main problem I stumbled upon (outside the fact that working in a multithread settings is not easy) is that I pass around a context everywhere
<amz3`>I'd like to make it a fluid
<paroneayea>amz3`: do you really think you'll need multithread support anyway?
<paroneayea>amz3`: more interesting would be if it can cooperate the new "suspend on port i/o" stuff for the guile asynchronous stuff in new guile
<paroneayea>eg, work with fibers
<paroneayea>if users need true parallelism, they can always break out processes and do message passing :)
<amz3`>I'll think about it
<amz3`>what is the difference between (with-mutex mutex body ...) and (with-input-from-file filename thunk)
<davexunit>the first one is a macro
<amz3`>with-mutex takes a `body ...', where `with-input-from-file' takes a thunk
<davexunit>the second one is a procedure
<amz3`>ah ok
<amz3`>thx
<amz3`>that is all?
<davexunit>besides the fact that they do entirely different things, yes.
<amz3`>my questions is specifically about the thunk vs body ...
<amz3`>I think you are right
<davexunit>thunk is a procedure
<davexunit>body .. is syntax
<davexunit>a thunk is a procedure with no arguments
<amz3`>another difference it makes sens to pass 'with-input-from-file' to procedure as argument, where it doesn't makes sens to do such a thing with `with-mutex`
<amz3`>if with-mutex was procedure I mean, It could be passed as argument
<amz3`>but there is no interest in making a proc
<amz3`>i think
<davexunit>both ways make sense
<davexunit>oftentimes the procedure version is named "call-with" rather than just "with"
<davexunit>and the macro version uses "with"
<davexunit>with-foo being syntactic sugar for call-with-foo
<amz3`>hmm
<davexunit>they are both useful in different ways
<stis>Map is {1-a,2-b,3-c}, X is {1,2}, mapset(X,Map,Y).
<stis>Y = {a,b}.
<stis>\\me is eating my owwn dog food
<stis>ACTION is eating my own dog food
<stis>next step is to avoid enable = and == to know about sets, currently to test set equality I need to have a special operator
<stis>I plan to make a guile class of the set and then guiles internal hash and equal? will know about it, this will enable = and == do do what we want.
<stis>a cool thing about the set is the hash of the set.
<stis>two elements e1, e2 lead to the hash (xor (hash e1) (hash e2))
<stis>xor beeing distributive and commutative and idempotent works great to enable a scalable hash
<stis>which means that sets of sets are pretty darn fast
<stis>so if e, with hash eh, belongs to set S, with hash hS, then the new set hash of the set with e removed is (xor he hS)
<stis>and becaise the order of (xor he1 he2 he3 ...) is unimportant and (xor e1 e1 e) = e, we are golden
<stis>I have one todo remaining though, the empty set should have a special hash value, currently it is 0
<stis>which is not so good