***sethalve_ is now known as sethalves
<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>Actually, this happens with the simplest guile webserver without any artanis. :( <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>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>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 <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 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>or (call-with-input-string "you_file" get-string-all), it will read all the content as string at once from "your_file" <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 <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 <DerGuteMoritz>ugh, academics, aren't that these people with lab coats and glasses <brendyn>yeah like how do you do emacs' string-replace <janneke>brendyn: yes, well, if you like to dismiss something, any negatively perceived statement will do, won't it? <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 <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 <civodul>janneke: substitute* is a macro in Guix, used as a replacement for sed <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 <janneke>DerGuteMoritz: this is so weird, why is string/regexp replacing; one of the most important things, not-standardized and overly complex? <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 <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>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 <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 :-) <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 <DerGuteMoritz>brendyn: also don't feel bad about implementing something that has been implemented before (even hundreds of times before) <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>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)) <brendyn>guix seems exciting. is it going to be glorious? *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? <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 <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. <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 <janneke>civodul: as it enables non-root installs of lilypond + its 15 dependencies <janneke>civodul: many upstreams say: we not care for mickysoft, go away <janneke>civodul: or, why would you want to cross build? <civodul>janneke: for small devices, and to port the distro to new architectures <nalaginrut>civodul: but is it possible to support compiled packages in Guix? <brendyn>all i get is ;;; <stdin>:476:16: warning: possibly unbound variable `:P' <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 <nalaginrut>brendyn: use letrec when you need bind something in a recursive way <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: "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>RPM and deb have much more than that <nalaginrut>well, for RPM, it plus a signature/validation part <civodul>nalaginrut: it's out-of-band, and not implemented yet <brendyn>ah, thanks nalaginrut. how do i add new line characters <brendyn>with one way is (newline) but it seems cleaner to add the new line character to string-append somehow <brendyn>is it less efficient to call display and newline separately? <nalaginrut>I think it's fine to call it separately, but it's more elegant if you use 'format' <brendyn>now i wonder how to convert this so itd work with cat ... | guile -c <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 <brendyn>hmm it seems like recursion is not possible with anonymous procedures? <stis>brendyn: try use the following, (define-syntax-rule (fn (nm . args) . code) (letrec ((nm (lambda args . code))) nm)) <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>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>doubtfully anywhere near the best solution but it works <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 :-) <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. <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" <dsmith>wingo, Howdy. Did you happen to see the bug I posted about integer->char failing in rtl.test ? *dsmith heads off to fix all the servers that have crashed.. (: <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. :( <brendyn>i wonder if anyone is going to write a replacement for Tar <brendyn>Maybe they will call it Car, Cloud Archive. *brendyn does not support such bad language <brendyn>nalaginrut: What did you want me to do with format? <wingo>shanecelis: does meta/guile examples/web/simple.scm work for you on the second go? <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. <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>can you explain the main advantage / difference between syntax-case and syntax-parse? <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 <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>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 <tupi>all guilers went on a trip on jupiter's 3rd moon <agumonkey>nobody set a backtracking continuation beforehand ? foolish. <tupi>backtracking before hand is amazing <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?