IRC channel logs

2013-07-08.log

back to list of logs

<dsmith>Howdy, Guilers
***sethalve_ is now known as sethalves
<nalaginrut>morning guilers~
<shanecelis>Hi guilers, I was trying to use artanis (a guile sinatra-like web router), and it seems to stop responding after handling the first request. Weird, right?
<shanecelis>Filed an issue on its github: https://github.com/NalaGinrut/artanis/issues/9
<shanecelis>Actually, this happens with the simplest guile webserver without any artanis. :(
<cky>:-/
<shanecelis>I'm using Guile 2.0.9. I'll try grabbing Guile from git and see if the issue is present there as well.
<nalaginrut>shanecelis: heya! how is it now?
<nalaginrut>it's OK for 2.0.9 released tarball
<nalaginrut>Artanis plans to be based on 2.0.9 released tarball
<nalaginrut>if it's no OK for you, maybe there's something Guile problem occurs under OSX?
<brendyn>I cannot even figure out how to open a file in guile :(
<nalaginrut>brendyn: open-file
<nalaginrut>well, I do think we need a 'learn Guile in a hard way'
<nalaginrut>it's not about grammar of Scheme, but the practical example of guile
<brendyn>(open-file "../.bash_profile" "r")
<brendyn>$2 = #<input: ../.bash_profile 9>
<brendyn>but how to display the file
<brendyn>i feel like giving up on scheme
<muep_>open-file gives you a file object that you can read from
<muep_>quite similar to e.g. fopen in the C programming language
<brendyn>(read (open-file "../.bash_profile" "r"))
<brendyn>ERROR: In procedure read:
<brendyn>ERROR: In procedure scm_lreadr: ../.bash_profile:2:1: Unknown # object: #\\newline
<muep_>I think read would try to read s-expressions from the file
<brendyn>i just makes me angry at myself that i can spend an hour on something so simple with all this documentation and still fail
<muep_>I think you should read the i/o port section of the guile manual
<muep_>brendyn: (use-modules (ice-9 rdelim))
<muep_>(define f (open-file "somefile.txt" "r"))
<muep_>after that, you can use (read-line f) to get lines of text from the file
<nalaginrut>brendyn: even you use python/ruby/C/C++, the operation is the same
<nalaginrut>brendyn: open it, then read it with proper function
<nalaginrut>brendyn: you may use get-string-all in this situation
<nalaginrut>brendyn: 'read' is not proper here
<nalaginrut>or (call-with-input-string "you_file" get-string-all), it will read all the content as string at once from "your_file"
<brendyn>alright i will try these
<DerGuteMoritz>call-with-input-file, not -string
<nalaginrut>yup..;-P
<brendyn>i have a sad problem
<nalaginrut>what?
<brendyn>i spent so long confused about what language i should learn as a beginner and thought id figured it out with scheme/lisp but i dont really know i feels like its hard to figure anything out with it
<civodul>Hello Guilers
<civodul>good news: GNU remains in place! http://www.newsday.co.zw/2013/07/02/gnu-remains-in-place/
<civodul>:-)
<janneke>brendyn: scheme/lisp is a very good choice, imho
<janneke>brendyn: there are some things, like reading a text file and substituting pieces in strings
<brendyn>janneke: i have heard sad comments like scheme being for academics
<janneke>brendyn: that seem overly complicated in scheme
<systemovich>civodul: :-)
<DerGuteMoritz>ugh, academics, aren't that these people with lab coats and glasses
<brendyn>yeah like how do you do emacs' string-replace
<brendyn>DerGuteMoritz: That's a chemist :P
<janneke>brendyn: yes, well, if you like to dismiss something, any negatively perceived statement will do, won't it?
<civodul>brendyn: not that i want to show off, but see substitute* in http://lists.gnu.org/archive/html/bug-guix/2013-01/msg00060.html
<civodul>it works pretty much like sed
<DerGuteMoritz>brendyn: how are you going about learning scheme?
<brendyn>janneke: this comment was not from a troll
<brendyn>DerGuteMoritz: well i have done a bit of sicp and i like Learn Scheme in Fixnum days
<brendyn>but its quite math intensive
<brendyn>sicp up to 1.11 or so
<janneke>civodul: Hmm?
<janneke>Info-search: Search failed: "substitute\\\\*"
<DerGuteMoritz>ok if you finished those then you should be in a pretty good position to be able to understand reference documentation
<brendyn>civodul: showing off is good
<brendyn>documentation looks alien to me
<civodul>janneke: substitute* is a macro in Guix, used as a replacement for sed
<janneke>civodul: well exactly my point
<civodul> http://git.savannah.gnu.org/cgit/guix.git/tree/guix/build/utils.scm#n377
<civodul>ah ok
<janneke>civodul: in python, it's import re; re.sub (regexp, replace, string)
<janneke>yes, regexp-replace-substitute/global or whatever it's called
<brendyn>i think i have learnt there are things where scheme is very inappropriate, like one liner things that you would do in perl or awk/sed if you have grey hair
<janneke>and whatever you built into guix -- anything you *can* build in guile, tends to be much more powerful and clean than what people build in python
<DerGuteMoritz>janneke: (use regex) (string-substitute regexp replace string) in chicken
<brendyn>from what ive read python is still very good. not to be mocked
<DerGuteMoritz>it's not a property of scheme that some apis are unwieldy :-)
<civodul>(use-modules (ice-9 regex)) regexp-substitute/global
<DerGuteMoritz>brendyn: I would ignore these kinds of stereotypes
<brendyn>DerGuteMoritz: which ones?
<DerGuteMoritz>any
<janneke>DerGuteMoritz: this is so weird, why is string/regexp replacing; one of the most important things, not-standardized and overly complex?
<brendyn>i mean which ones were said
<brendyn>about perl?
<DerGuteMoritz>janneke: is it standardized in python? ._)
<DerGuteMoritz>:-)
<janneke>brendyn: python is a fine language, it's just not inspiring to me; not the way guile is
<DerGuteMoritz>brendyn: stereotypes are not a good way to inform choices, they are oversimplifications
<brendyn>janneke: cool, what inspires you about it personally
<brendyn>DerGuteMoritz: how am i to distinguish them between sterotype and fact?
<janneke>brendyn: things like the url that civodul posted
<brendyn>i wish i could understand that program
<janneke>brendyn: after you get started, you start to realise that many more things are lists than you can imagine
<DerGuteMoritz>brendyn: by trying it yourself
<DerGuteMoritz>by learning
<brendyn>DerGuteMoritz: thats the problem. im trying to figure out what to do as a beginner. if i spend years learning before i figure out ive been stupid all the time that wouldnt be good
<janneke>brendyn: and this list paradigm lends itselft beautifully to refactoring code into powerful, yet clean and easy to understand concepts
<DerGuteMoritz>or from people you personally trust
<DerGuteMoritz>brendyn: by learning I mean building things, not just reading about things
<brendyn>its hard for me to figure out what i want to build
<janneke>civodul: i should look at guix some time soon
<DerGuteMoritz>in my experience the best way to understand something is to build it
<DerGuteMoritz>aka constructivisim I think
<janneke>civodul: have you looked at GUB at all?
<janneke>civodul: does guix do cross-building too?
<brendyn>can you explain what that script does?
<brendyn>im building something that you would probably think is trivial. it has taken two hours
<brendyn>its just appending line numbers to a file
<civodul>janneke: i looked at GUB when you mentioned it at the GHM in Den Hague :-)
<DerGuteMoritz>brendyn: this is exactly what I mean! keep going
<civodul>janneke: Guix does cross compilation: http://savannah.gnu.org/forum/forum.php?forum_id=7634
<civodul>(to appear in the forthcoming 0.3 release)
<DerGuteMoritz>brendyn: I mean, don't think about that others might find it trivial, you don't build it for them but for yourself
<janneke>civodul: wow!
<DerGuteMoritz>brendyn: also don't feel bad about implementing something that has been implemented before (even hundreds of times before)
<civodul>howdy wingo!
<DerGuteMoritz>brendyn: that's even better as then you have plenty of reference on how others approached the problem
<janneke>civodul: are targets macos-x and mingw supported yet?
<brendyn>its just that my friend came along and solved it in 5 different languages in few minutes before i could even figure out how to open a file
<brendyn>and they all took one line. the scheme looks like it will be longer than all of them
<brendyn>well, almost
<brendyn>does read-line have line number build in ?
<civodul>janneke: nope; the focus is on GNU/Linux currently
<janneke>brendyn: (define (gulp-file file-name) (call-with-input-file file-name get-bytevector-all))
<wingo>morning :-))
<brendyn>guix seems exciting. is it going to be glorious?
<youlysses-laptop>civodul: And hopefully/eventually GNU/Hurd.
*youlysses-laptop should really be in-bed.
<civodul>brendyn: of course, and perhaps it'll be on TV even!
<janneke>civodul: would it be useful to see if i can move from gub to guix?
<brendyn>civodul: fro reals!?
<brendyn>better than pacman/dpkg?
<janneke>civodul: we use it mainly for creating binary packages
<wingo>civodul: just pushed another tree-il tweak
<wingo>i have an anf module now, currently experimenting with cps also
<civodul>wingo: woow!
<wingo>also swamped at work and family visits, so things are going quite slowly
<civodul>janneke: dunno, we'd need to see exactly how you use it, etc.
<wingo>eurosummer :)
<civodul>wingo: yeah, i know what you mean ;-)
<wingo>now that it's finally here anyway
<janneke>civodul: one of the major things is gub is that all packages are made relocatable
<janneke>civodul: that was necessary for windows/mingw anyway, but comes in handy for gnu/linux
<civodul>ah, not the case here
<janneke>civodul: as it enables non-root installs of lilypond + its 15 dependencies
<civodul>yeah but that requires patching
<civodul>i see
<janneke>civodul: yes
<janneke>civodul: many upstreams say: we not care for mickysoft, go away
<civodul>heh
<janneke>civodul: or, why would you want to cross build?
<civodul>janneke: for small devices, and to port the distro to new architectures
<nalaginrut>brendyn: I think guix better than packman/dpkg
<nalaginrut>civodul: but is it possible to support compiled packages in Guix?
<nalaginrut>or the building have to be long
<nalaginrut>building time
<brendyn> http://paste.lisp.org/display/137968 can someone help point out why this doesnt work?
<brendyn>all i get is ;;; <stdin>:476:16: warning: possibly unbound variable `:P'
<brendyn>ill be back in a sec -- dishes
<civodul>nalaginrut: Guix uses pre-built binaries when available, and otherwise falls back to building locally
<nalaginrut>civodul: oh~then I have to say Guix is definitely better than packman/dpkg
<civodul>of course it is ;-)
<nalaginrut>brendyn: you need letrec*
<nalaginrut>rather than let
<nalaginrut>brendyn: use letrec when you need bind something in a recursive way
<nalaginrut>civodul: Could Guix support rpm/deb?
<nalaginrut>brendyn: other languages have shorter code to open/read a file is not a big deal, if you like it, you may use macro to define a shorter things than python/perl..., which is just syntax sugar
<civodul>nalaginrut: no
<nalaginrut>civodul: so what's the binary package format?
<nalaginrut>a new format?
<civodul>nalaginrut: "Nix archive" (nar), which is similar to tar with additional meta-data
<nalaginrut>ok, so it's a binary archive plus meta header, like RPM/DEB?
<civodul>it's a binary archive
<civodul>RPM and deb have much more than that
<nalaginrut>well, for RPM, it plus a signature/validation part
<nalaginrut>so, is nar have signature mechanism?
<nalaginrut>does
<civodul>nalaginrut: it's out-of-band, and not implemented yet
<brendyn>ah, thanks nalaginrut. how do i add new line characters
<nalaginrut>try (newline fp)
<brendyn>with one way is (newline) but it seems cleaner to add the new line character to string-append somehow
<brendyn>whats fp?
<nalaginrut>fp is the port opened for your file
<brendyn>ah
<brendyn>wait but that file is input
<brendyn>not output
<nalaginrut>alright, just (newline)
<brendyn>is it less efficient to call display and newline separately?
<nalaginrut>BTW, I suggest you try 'format'
<nalaginrut>I think it's fine to call it separately, but it's more elegant if you use 'format'
<brendyn>i dont know what that does
<brendyn>now i wonder how to convert this so itd work with cat ... | guile -c
<stis>tjena guilers
<stis>DeGuteMoritz: I read that you where looking at syntax-parse!
<stis>you could download guile-syntax-parse and look at the racket macther implementation there
<stis>it's shows it in action!
<stis>another source id to look at the common lisp loop macro I did with syntax-parse at
<stis> https://gitorious.org/guile-cl
<stis>DerGuteMoritz: ^^
<brendyn>hmm it seems like recursion is not possible with anonymous procedures?
<brendyn>since it cant call its self
<DerGuteMoritz>stis: oh hey, where did you read that?? :-)
<stis>brendyn: try use the following, (define-syntax-rule (fn (nm . args) . code) (letrec ((nm (lambda args . code))) nm))
<brendyn>I have a solution!!!!
<brendyn>cat file.txt | guile -c '(use-modules (ice-9 rdelim)) (letrec ((:P (lambda (n) (let ((l (read-line))) (unless (eof-object? l) (display (string-append (number->string n) " " l)) (newline) (:P (+ n 1))))))) (:P 1))'
<stis>and then use it as (fn (self x y) (if (< x 100) (self (+ x 1) (+ x y)))
<brendyn>does the : mean anything in guile?
<brendyn>it seems to work anyway, but emacs highlights it whereas it doesnt highlight things without colons
<stis>perhaps it's a keyword no?
<brendyn>stis: ill have a look at that in a moment,
<brendyn>i dont understand what it means looking at it
<brendyn>nalaginrut, DerGuteMoritz ^
<brendyn>doubtfully anywhere near the best solution but it works
<stis>brendyn: about the colon, check out http://www.gnu.org/software/guile/manual/html_node/Keywords.html#Keywords
<brendyn>funny that it doesnt break my program then
<brendyn>can you explain that define-syntax-rule?
<stis>yeah, but it might show that keyword are identifiers with no module home!
<stis>aha guile permits :keyword but defaults to #:keyword, emacs doesn't know about this
<stis>so :P is just a normal identifier
<stis>so the emacs coloring is a red herring :-)
<brendyn>ahk
<brendyn>if i use #:P guile errors
<stis>brendyn: btw ((fn (self x y) (if (< x 100) (self (+ x 1) (+ x y)) y) 100 0) = 0 + 1 + 2 + 3 + ...+ 99
<brendyn>well my program must go until read-line gives EOF
<stis>yes keywords are not identifiers, i was out on the wrong path there.
<brendyn>identifiers are symbols?
<stis>fn is just shows how easy it is to construct syntax-suger for a named annonymous function (ouch)
<stis>It is also possible to introduce self as a convention, but schemers doesn't like those tricks much.
<stis>better to be explicit to all introduced variables
<DerGuteMoritz>there's also a SRFI that defines something like this by the name of "rec"
<DerGuteMoritz>SRFI 31
<dsmith>wingo, Howdy. Did you happen to see the bug I posted about integer->char failing in rtl.test ?
<dsmith>wingo, (obviouly on master)
*dsmith heads off to fix all the servers that have crashed.. (:
<dsmith>s/(:/:(/
<brendyn>named anonymous 0.o
<wingo>dsmith: nope, haven't seen it yet
<wingo>dsmith: could be you need to do a full recompile
<wingo>there have been some ABI-incompatible changes recently to the VM
<shanecelis>(web server) is not working on 2.0.9 and the head of the tree for Guile on Mac OS X. It serves up the first request but no subsequent ones. :(
<wingo>bummer!
<brendyn>i wonder if anyone is going to write a replacement for Tar
<brendyn>Maybe they will call it Car, Cloud Archive.
*brendyn kids
*brendyn does not support such bad language
<brendyn>nalaginrut: What did you want me to do with format?
<shanecelis>good news: the internet socket example server does work on Mac OS X. Hmm, where is this (web server) problem coming from? http://www.gnu.org/software/guile/manual/guile.html#Internet-Socket-Examples
<wingo>shanecelis: does meta/guile examples/web/simple.scm work for you on the second go?
<shanecelis>wingo: No, it doesn't.
<wingo>that should be simple enough to trace at a repl
<wingo>maybe we should add a --trace arg to guile
<shanecelis>wingo: I'm happy to run whatever diagnostics you suggest.
<wingo>i am suggesting that you ,trace it at the repl :)
<wingo>see "tracing traps" in the manual, it has some examples
<shanecelis>something like this: ,trace (load "examples/web/hello.scm")
<shanecelis>wingo: Hmm, so when I run it from the REPL, the first response is handled, second isn't as before, but if I CTRL-C, and re-run (run-server handler), the first response is handled, second isn't.
<shanecelis>The ,trace (run-server handler) shows a lot of information, but it doesn't show anything new when handling the first or failing to handle the second request.
<shanecelis>On subsequent runs of ,trace (run-server handler) it doesn't emit anything. :|
<shanecelis>"doesn't show anything new" meaning no new trace lines are emitted that provide any clue as to what is going on. Weird, right?
<stis>DerGuteMoritz: I read the logs, ;-) you checked syntax-parse out at least Jun 25.
<DerGuteMoritz>ha
<DerGuteMoritz>you work for the NSA I guess!
<stis>hehe, don't trust your felolow chatter!
<DerGuteMoritz>superficially syntax-parse does not look very elegant but maybe I'm just not used to all the [] and #'
<stis>please look at some example that make use of it, it's easier to get a feeling for it's usefullness then.
<DerGuteMoritz>I'm sure it's useful, yeah!
<DerGuteMoritz>can you explain the main advantage / difference between syntax-case and syntax-parse?
<DerGuteMoritz>*advantage of ... compared to
<DerGuteMoritz>argh
<DerGuteMoritz>you know what I mean :-)
<stis>yeah
<stis>1. Backtracking matching of syntaxes
<stis>2. Good control with cuts.
<stis>3. A system for smart error handling
<stis>4. modularized matching without needing to put thing in a tail call framework aka macros
<stis>That's my 2c, it also contains a lot of other features but the above is what I mostly use
<DerGuteMoritz>error handling sounds good
<DerGuteMoritz>can you elaborate on 4.?
<stis>Well you could define a pattern as (x:a y:b z:c) with a,b,c, beeing abstarct pattern matchers or syntax classes as well
<stis>and they contain it's own modularized macro handling.
<stis>If you would do the same with macros directly you would need to have some tail call convention
<stis>So when the pattern matcher is ready you will have the results of the syntax classes logic at your expansion creation
<stis>for exampl a could define a subvar exp form it's expansion and you would reach that by x.exp
<stis>sorry I have to go no CU
<DerGuteMoritz>ok I didn't get all of that
<DerGuteMoritz>did he mean something like extensible syntax?
<DerGuteMoritz>like being able to add new match operators to the `match' form or something?
***linas__ is now known as linas
***sneek_ is now known as sneek
***janneke1 is now known as janneke
<stis>DerGuteMoritz: yeah, its sort of extensible syntax, but with some twists.
<stis>anyway of cause you can many times achieve similar structure by pattern match syntax-case and send the matches to sub functions
<stis>that themself contain syntax-case etc
<agumonkey>hello there, anybody alive in here ?
<ijp>nope
<tupi>all guilers went on a trip on jupiter's 3rd moon
<ijp>none survived
<agumonkey>nobody set a backtracking continuation beforehand ? foolish.
<tupi>backtracking before hand is amazing
<tupi>:)
<agumonkey>Please don't own me on my joke attempts ~_~
<agumonkey>I'm having trouble replicating the sample goops code in the documentation. My instance slots are bound to nothing
<tupi>could you pastbin somewhere?
<agumonkey>yep, in progress