IRC channel logs

2015-09-25.log

back to list of logs

<sirgazil>Hi :)
<sirgazil>I'm writing a script to do this:
<sirgazil>$ program build /path/to/project
<sirgazil>The program adds the path to Guile's load path and then uses a variable defined in a module of the project. Like this:
<sirgazil> https://multimedialib.files.wordpress.com/2015/09/pantallazo.png
<sirgazil>But I get this error:
<sirgazil>sitio/core.scm:8:2: In procedure module-lookup: Unbound variable: resources
<sirgazil>Could you please point me to my mistakes? :)
<sirgazil>If I define the build process in a REPL and call it, it works, but in the script in the screenshot above it fails.
<mark_weaver>sirgazil: the module lookup happens at compile time, before the load path modification has been done
<mark_weaver>and 'use-modules' is not meant to be used within a procedure like that
<mark_weaver>there are ways to do what you want, but it's a bit more awkware
<mark_weaver>awkward
<sirgazil>I imagined that, but had to try the noob way :)
<sirgazil>mark_weaver: is it too difficult for a beginner?
<mark_weaver>no, it's not that bad, give me a minute
<sirgazil>Ah, ok, thanks.
<mark_weaver>at the moment I'm typing this on an experimental GuixSD for Yeeloong system, and am limited to the emacs 'eww' web browser. I can't seem to figure out how to get it to scroll to the right, so I can't see the entire text of your code. can you paste the text instead to http://paste.lisp.org/new ?
<OrangeShark>sirgazil: it looks like in (display resources) the variable resources does not have a value
<mark_weaver>OrangeShark: no, the problem is that the module hasn't been loaded at the point when this top-level form was compiled.
<sirgazil>mark_weaver: sure, give me a sec...
<sirgazil>mark_weaver: this is the top-level program:
<sirgazil> http://paste.lisp.org/display/155716
<sirgazil>and module:
<sirgazil> http://paste.lisp.org/display/155717
<mark_weaver>will this 'build' procedure be called more than once, with different projects, in a given guile process?
<sirgazil>no, just once. The program builds and exits.
<mark_weaver>okay
<mark_weaver>probably the easiest approach here is to set the load path before guile runs
<mark_weaver>it can be done after, but it's a bit more of a pain
<mark_weaver>you can combine a shell script and a guile script into one file
<sirgazil>I see. That's what I was doing initially but manually. But, yes, I'll write a shell script then.
<sirgazil>thanks mark_weaver :)
<mark_weaver>so then (sitio core) can just include "#:use-module (website resources)" in its 'define-module' form
<mark_weaver>and you can remove the 'add-to-load-path' and 'use-modules' from 'build'.
<sirgazil>right.
<kristofer>anyone familiar with guile-json?
<kristofer> http://paste.lisp.org/display/155719
<kristofer>artanis/third-party/json/upstream/syntax.scm:35:4: In procedure list->hash-table:
<kristofer>artanis/third-party/json/upstream/syntax.scm:35:4: Throw to key `match-error' with args `("match" "no matching pattern" ((course-list)))'.
<mark_weaver>kristofer: where's the code that contains the symbol 'course-list' ?
<mark_weaver>and how does that relate to the paste you provided above?
<kristofer>mark_weaver, I annotated the paste with the course list definition
<mark_weaver>kristofer: there must be somewhere else that 'course-list' is getting used, where it somehow is interpreted as a symbol instead of a variable reference
<mark_weaver>I'm not familiar with artanis, so maybe I don't have enough relevant knowledge to help with this.
<kristofer>using the repl, I've been trying to (scm->json (json (object (array course-list))))
<kristofer>I've been modifying the return from nested lists, to a list of pairs, etc. trying to figure out what structure will work to build a json string
<mark_weaver>kristofer: looks like you need to put a comma before 'course-list', like this: (scm->json (json (object (array ,course-list))))
<mark_weaver>to prevent it from being treated as a literal
<mark_weaver>although I'm not sure that's quite right either, because 'object' wants key-value pairs after it
<mark_weaver>kristofer: do you want the top-level JSON to be an array, or an object? if an object, what key+value pairs do you want it to have?
<kristofer>I made another annotation for the desired output
<mark_weaver>the 'json' macro acts a little bit like quasiquote, which means that everything within (except for certain special keywords) as quoted literals. in order to reference a variable from within a 'json' form, you need to 'unquote' it with comma.
<mark_weaver>kristofer: okay. I'm not sure using the 'json' macro is the best approach here, since it seems to be geared toward templating where most of the structure is constant, but I guess it would look something like this:
<mark_weaver>(json (object ("courses" (array (object ("id" "6357") ("name" "Raymond Park DGC")) (object ("id" "349") ("name" "Brookside Park")) ...))))
<mark_weaver>probably you want a procedure to create the json for each element of this array, something like (define (course->json id name) (json (object ("id" ,id) ("name" ,name))))
<mark_weaver>and then, if 'course-list' is a scheme list of the results of 'course->json', I guess that something like this will create the final json: (json (object ("courses" (array ,@course-list))))
<mark_weaver>but I haven't tested any of this, nor am I familiar with guile-json. I'm just reading the code and README of guile-json and going from there...
<mark_weaver>we're actually close to adding json support to guile core, but we'll be using a different API that guile-json.
<mark_weaver>s/that/than/
<mark_weaver>(although of course guile-json will still be available and will continue to work)
<mark_weaver>with the JSON API that will soon be in core guile, your desired output will be produced with something close to this:
<mark_weaver>(write-json '(@ ("courses" . ((@ ("id" . "6357") ("name" . "Raymond Park DGC)) ...))))
<mark_weaver>so, you just create normal lisp list structure where JSON arrays are simply scheme lists containing the elements, and JSON objects are scheme lists of the form (@ (<key> . <value>) (<key> . <value>) ...)
<goglosh>anyone here has experience with guile-wm?
<mark_weaver>goglosh: iirc, davexunit and civodul have both tried it
<goglosh>it was probably civodul who made the weird config I'm using now
<goglosh>:P
<mark_weaver>I guess they found it to be not quite mature enough yet, although I think we're all excited about its potential
<mark_weaver>it just needs more love
<goglosh>not quite mature.. hum
<goglosh>yess
<goglosh>ACTION loves guile-wm
<goglosh>well I'm trying
<mark_weaver>I'd really love to switch to something like guile-wm
<goglosh>well
<goglosh>there is stumpwm
<goglosh>I used that in my old sys
<artyom-poptsov>sneek: later tell davexunit Thanks! If you're interested you may check out the Guile-SSH master branch -- I fixed some bugs and added handling of multiple values to 'with-ssh' after the 0.8.0 release.
<sneek>Got it.
<kristofer>mark_weaver, thank you, I'll keep experimenting!
<nalaginrut>morning guilers~
<artyom-poptsov>Hello nalaginrut
<nalaginrut>heya
<nalaginrut>ACTION is writing DB models...
<goglosh>evening nalaginrut
<nalaginrut>;-)
<paroneayea>o/
<amz3>héllo :)
<ArneBab_>paroneayea: I think the reddit thread is pretty tame — I’m used to much worse when writing anything about Freenet ☺
<dsmith-work>Happy Friday, Guilers!!
<paroneayea>ArneBab_: true :)
<calher>"SLIB does not support Guile 2.0 yet. Ignoring.
<calher>Why doesn't Guile support SLIB yet, and where are people working to fix this?
<paroneayea>calher: you can use SLIB
<paroneayea>calher: you just need a newer-ish version than the one provided by debian, at least
<paroneayea>but newer ones work fine.
<calher>Oh, OK.
<calher>Is anyone working on guile-scsh?
<amz3>AFAITL no
<calher>TL?
<amz3>AFAIK
<paroneayea>calher: not afaik, and it might need a fresh port
<amz3>I'm not sure what the value of scsh
<paroneayea>there are possible legal problems with the current one
<calher>paroneayea: Legal? WTF.
<amz3>I had a look at it looking for some contribution, but it seems to me that it duplicates stdlib
<paroneayea>some of the headers say "the usual GPL terms, including can't be sold" or something, which actually is incompatible with the GPL
<ArneBab_>ouch :(
<paroneayea>which is not a problem in scsh
<paroneayea>just the guile port.
<calher>paroneayea: Ignorant words like those raise my blood pressure.
<calher>"GPL ... cant be sold" !!!
<please_help>mark_weaver: it seems chicken is able to somehow detect segfaults, and the repl stays alive even when a segfault occurs. Any idea how that works?
<calher>Oh my, this guy is a huge non-commercial freak. I want to hit him.
<calher>(Reading the copyright file.)
<paroneayea>calher: I think it was a mistake on part of the person porting it
<paroneayea>I suspect they just didn't understand
<paroneayea>I think I sent an email out to them reaching out
<calher>paroneayea: You mean, that non-commercial is a no-no? Because he was very clear about its being NC.
<paroneayea>but it was to an address of like 15 years ago
<ArneBab_>calher: oh yes…
<calher>afk
<ArneBab_>calher: non-commercial is a no-no for any free software project. It prevents growing.
<ArneBab_>calher: I wrote something on the danger of noncommercial clauses: http://draketo.de/light/english/politics/free-culture-danger-noncommercial
<ArneBab_>“NC covered works trick people into investing in a dead end”
<ArneBab_>using NC covered works is like learning to use Photoshop and then realizing that you aren’t allowed to earn a little extra by improving wedding-images without shelling out 3000€ for a creative suite license. And that means, that you can’t move in small steps from a boring day job to a professional creative life.
<ArneBab_>^ binds people to companies
<sirgazil>paroneayea: Hi :) What's the emacs theme you're using in the first screenshot in your wisp post?
<paroneayea>sirgazil: hello! It's naquadah
<paroneayea>I really like it!
<paroneayea>sirgazil: I also use rainbow-delimeters to get that nice colored parenthesis effect
<sirgazil>paroneayea: thanks. I use rainbow-delimiters too but the rainbow is gone in the dark theme I'm using. Did you have to customize your rainbow with naquadah?
<paroneayea>sirgazil: the rainbow is pretty good out of the box but I made a small tweak to the naquadah theme because two of the colors look too similar when by each other
<paroneayea>it's two yellow-browns right next to each other
<paroneayea>otherwise naquadah is great
<paroneayea>sirgazil: the adjustment I madehttp://pamrel.lu/d6fff/
<paroneayea>er
<paroneayea>sirgazil: the adjustment I made http://pamrel.lu/d6fff/
<sirgazil>Oh, thanks. I'll try it :)
<paroneayea>I really like the naquadah theme though
<paroneayea>sirgazil: I also have a nice hack using a *different* parenthesis color package
<paroneayea>that highlights the sexps my point currently is in
<paroneayea>see this:
<paroneayea>sirgazil: http://dustycloud.org/tmp/emacs_lisp_setup.png
<paroneayea>see the background?
<paroneayea>on the parentheses
<paroneayea>that way it highlights all the encompassed parens
<paroneayea> https://github.com/cwebber/cwebbers-emacs-config/blob/master/modes/highlight-parentheses.el
<paroneayea>sirgazil: maybe of interest to you, maybe not
<paroneayea>but I'm never lost in lisp!
<sirgazil>yeah I'm interested in cognitive ergonomics, so yes :) Thanks
<paroneayea>sirgazil: \\o/
<amz3>cognitive ergonomics
<amz3>I'm reading a sum up of opencog, it's not cognitive ergonomic at all!!!
<amz3>naquadah is super nice, this makes me think i should try the rainbow thing, because I find out that since I code without it, my copy/paste rate has increased
<paroneayea>amz3: heh :)
<sirgazil>amz3: I've found par edit and rainbow delimiters very helpful
<amz3>I tried, paredit, but it does work well with my coding habits
<paroneayea>amz3: have you tried smartparens?
<paroneayea>it's like a more lax paredit
<paroneayea>it's like "hey, I'll give you some of paredit's features, but if you want to do things the old way, that's cool too"
<paroneayea>paredit is like "conform to the world of paredit!"
<amz3>paroneayea: it sound good, yeah, I will try that thanks
<taylanub>smartparens also has a "strict mode" AFAIK
<rekado>I really like paredit. If anything it doesn't go far enough for my tastes. (It allows improper deletion with C-w or C-<backspace>.) Once I got used to slurping and barfing sexprs I want it for everything, not just lispy languages.
<civodul>howdy, sirgazil!
<sirgazil>Hey civodul :)
<calher>ArneBab_: NC is non-free.
<calher>ArneBab_: You're right.
<taylanub>rekado: paredit-backward-kill-word ?
<taylanub>that's bound to M-DEL by default. I thought C-DEL is usually bound to the same thing as M-DEL, but maybe Paredit doesn't bind it.
<rekado>yes, M-DEL is fine, but C-DEL is not, and I'm used to using C-DEL more often for some reason.
<taylanub>rekado: for me, M-DEL and C-DEL are bound to the same thing (backward-kill-word) in emacs -q outside paredit. which C-DEL is the one you mean?
<davexunit>ACTION also uses C-DEL to kill words backwards
<paroneayea>killing and yanking, especially pulling things out of "the kill ring", alwasys sounds like necromancy to me
<calher>paroneayea: I always yank it after I kill.
<davexunit>paroneayea: I haven't learned the kill ring stuff very well
<davexunit>only recently did i realize that I could do C-u <number> C-y
<paroneayea>the kill ring is great stuff
<calher>C-u 2 C-y, or something
<paroneayea>browse-kill-ring is a GREAT extension btw
<calher>I'm happiest being close to a kill ring.
<paroneayea>lets you select what you want from the kill ring via a menu
<calher>YISS
<davexunit>paroneayea: oh interesting
<davexunit>I think I heard about that awhile ago
<davexunit>should try it out
<ArneBab_>does browse-kill-ring work with huge killings (i.e. after I killed 50 pages of text)?
<davexunit>talking about emacs can get really morbid really quick
<davexunit>Emacs: A Dark Comedy
<amz3>ArneBab_: are you asking if it's possible to kill a book in emacs?
<ArneBab_>amz3: just whether browse-kill-ring survives it :)
<ArneBab_>I *can* kill a full book, I know that :)
<davexunit>why is *unspecified* considered "truthy"? is it simply because the only "falsy" value is #f?
<davexunit>(if (set! foo "bar") 1 2) => 1
<dsmith-work>Wow
<davexunit>I've known about this property for awhile, but I'm just curious about the language design reason.
<mark_weaver>davexunit: it's just because #f (and #nil) are the only false values
<davexunit>mark_weaver: that was what I was thinking, thanks.
<mark_weaver>checking for truth is implemented as masking out the one bit that differs between #nil and #f and then comparing with tha value.
<davexunit>though I also think it's interesting that set! returns 1 value, unspecified, as opposed to 0 values.
<mark_weaver>it's historical, from before scheme had multiple values
<mark_weaver>ditto for many other things that have no useful value to return
<davexunit>I see, that makes more sense now.
<mark_weaver>multiple values weren't added until R5RS
<mark_weaver>davexunit: btw, I should mention that in the scheme standards, "unspecified" really means that *anything* could be returned, so it's not proper to assume that it's treated as true or false.
<mark_weaver>that guile returns a particular special value in that case is an oddity
<davexunit>yes, I don't actually think of unspecified as a true value, but Guile does let me write some odd code that lets me treat it that way.
<mark_weaver>e.g. in standard scheme, 'set!' might return #f or #t or 3.1415927 or whatever
<mark_weaver>yeah
<mark_weaver>I don't recommend it though
<mark_weaver>that's why I keep reminding people to put #t at the end of our phase procedures in guix
<mark_weaver>although there are probably hundreds of such errors :-(
<mark_weaver>I guess it's not a problem in practice, but it grates on me nonetheless :)
<davexunit>yeah, I'm pretty sure I pushed a patch recently that had such an error... I need to go fix it.
<davexunit>is there any conceivable way to make Guile bark at this stuff?
<davexunit>or are our hands tied?
<mark_weaver>well, the code that runs the phases in guix could check for *unspecified* as a return value and print an error
<mark_weaver>s/error/warning/
<mark_weaver>guile could also be modified to print a warning if *unspecified* is checked for truthiness, but that would slow down those checks and cause some code size growth.
<mark_weaver>adding the check in guix would entail a full rebuild of the world, I think, so it would have to wait for the next core-updates cycle. it might be a good idea though.
<mark_weaver>ditto for snippet return values
<davexunit>yeah, might be worth doing sometime.
<taylanub>I think it would be a (minor) improvement if most of the things which return *unspecified* would instead return zero values, but I guess the effort to do that and the compatibility price wouldn't pay off...
<davexunit>I have written procedures that return *unspecified* on occasion
<davexunit>I wouldn't know how to express that otherwise
<taylanub>if there's no sensible return value, why return one? :)
<taylanub>I started a thread on that on comp.lang.scheme the other day (tell me if you know of a better general-purpose Scheme forum...), but it seems the only Usenet archive out there is Google Groups now which IIRC requires JavaScript? I also have http://taylanub.github.io/doc/scheme-values.html but that's from absent sketches and might not be very readable.
<taylanub>in case anyone was interested in a closer look at how zero-value returns would work out, that is
<taylanub> https://groups.google.com/forum/#!topic/comp.lang.scheme/CDlpbZc8IyE FWIW
<mark_weaver>bah, that page requires running (presumably non-free) javascript to even view
<mark_weaver>grr
<davexunit>yeah, google groups sucks.
<mark_weaver>anyway, I agree that if we were starting from scratch, it would be better for these things to return 0 values, but it would probably break a lot of existing code, and it seems like a relatively low priority to me.
<davexunit>thanks for the explanations.
<davexunit>it makes more sense now.
<davexunit>and yes, low priority indeed.
<mark_weaver>bah, our gvfs recipe depends on patchelf
<davexunit>mark_weaver: for #guix I imagine :)
<mark_weaver>indeed
<davexunit>the levenshtein distance is too low between the two channels :)
<mark_weaver>heh :)
<amz3>:))
<amz3>I always wondering why people keep inventing lisp languages, why do they just not say it's scheme without cc
<amz3>I am asking the question: https://news.ycombinator.com/item?id=10279266
<davexunit>so, the Occulus virtual reality isn't exactly great from a freedom perspective, but John Carmack just gave a presentation in which he live coded an application for it... in Racket.
<davexunit>that's pretty great from a Scheme publicity point of view.
<amz3>davexunit: what is his argument regarding racket and scheme in particular instead of C/C++ or Python?
<amz3>isn't he just fiddling with scheme?
<davexunit>it's a bit more than fiddling
<amz3>Yeah, I know he is doing *real stuff* but why scheme then
<davexunit>as a Schemer, shouldn't the answer be self-evident? :)
<amz3>obviously this this can not be compared to solving euler problems
<davexunit>John Carmack saw the advantages of s-expressions, macros, functional concepts
<davexunit>and chose Racket for its DrRacket IDE and its nice language system.
<amz3>to be honest, no functional concepts enlightned me as such
<amz3>since this comes to the conversation, I like a lot of thing about scheme and guile in particular but outside homoiconicity (?) there is nothing that I find extra-ordinar
<amz3>you can do everything you want in scheme and in other languages, it just that the syntax is way more pratical than say python
<daviid>amz3: macros are as powerful in python?
<amz3>daviid: this enters in the "homo-thing" category, yes python has no macro is ugly
<davexunit>you can do anything you want in assembly languages, too.
<davexunit>but it doesn't make doing those things easy.
<davexunit>this is just my own anecdote, but Scheme has enabled me to do more things more easily than any other language has.
<amz3>daviid: also they are macro framework for python
<amz3>yes, that's why I work hard to make the language i most pro-efficient
<davexunit>lexical scope, first-class functions, s-expressions, and macros are the most important factors to me.
<davexunit>and maybe another category or two to distinguish Scheme from Common Lisp and such.
<davexunit>other languages may have a subset of these features, but they rarely have all of them.
<daviid>if python/had used s-expr, the scheme macros, also for me especially :) goops, I may use it :)
<davexunit>javascript has lexical scope and first-class functions, but it has complicated syntax and no macro system.
<daviid>the syntax of these languages is just wrong
<amz3>the only thing intersting about javascript is prototype based inheritance
<davexunit>ruby has a metaprogramming system, but it has a very complex grammar, odd scoping, and their procedure objects are clunky to use.
<amz3>ACTION thinks guile needs another killer feature that is not scheme, call/cc or guix
<amz3>my high level understanding or rewriting calculus is very appealing
<amz3>anyway
<amz3>;)
<davexunit>Guile is almost entirely killer features, from my perspective. (I know that mainstream wouldn't agree)
<amz3>davexunit: your are biased to fsf :D
<davexunit>delimited continuations, pattern matching, sxml, srfi-1, etc.
<davexunit>the effort spent learning guile has paid off in spades.
<amz3>without disrepect, I hope I will be more pro-efficient in guile and will be able to tell why it a killer language
<davexunit>it has completely changed the way I think about, write, and design programs.
<davexunit>for the better, I think. ;)
<amz3>I saw you last commmit, it wasn't that great
<davexunit>they're aren't all gems ;)
<amz3>:))
<mark_weaver>amz3: learning the language is not enough, because you will naturally tend to write code in it similarly to how you did in other languages. you need to become exposed to the programming styles that are enabled by scheme.
<davexunit>my point is that, for me, Guile has been very well worth learning.
<davexunit>I'm not paid to write Guile, but the things I've learned from Guile inevitably affect how I write programs in those other languages.
<davexunit>I am *constantly* thinking "this would be easier to express in Guile"
<amz3>mark_weaver: yes!
<amz3>davexunit: that what I want to experience.
<daviid>yes, this is a very well know and old fact: unless you come to functional prgramming, lisp in general scheme in particular, you'll have a hard time to become a good programmer. I see that just reading java code from others, and catastrophic design of some nonetheless known and largely used libraries
<amz3>I already made use of the functional programming in a python program, It's an example of how it changed my design for the better
<amz3>it's a big problem i have: I don't read much code
<amz3>(I used to have complicated class that did the correct thing but functional approach was much better, simpler and more elegant in general, took me two years and guile to get to that point)
<amz3>the code is now mucccch simpler
<amz3>I did not implement it in guile yet
<davexunit>Guile enabled me to write a system for iteratively developing video games. there's plenty of work to be done on it, but it works and that amazes me.
<amz3>but basicaly it boils to to use "compose" procedure which doesn't exists in python at all
<davexunit>I've been meaning to glue Guix and Sly together for something fun... should do that sometime.
<ArneBab_>I just saw a freenet client app written in Scheme, and it was so elegant it totally awed me.
<amz3>ArneBab_: where is it?
<ArneBab_>currently only available via Freenet
<amz3>freenet seems more advanced than gnunet, at least the wikipedia page suggest more applications
<ArneBab_> http://127.0.0.1:8888/freenet:CHK@jlljY~S~8ufWtC~aMNg2F2HtH~SP9tKeUFIcgOBbsyo,blM~2cBInFFaWKOpmE0f2nhWCq8~IUlyfNiiyJ069CE,AAMC--8/fcp.rkt.html
<amz3>this is a freenet uri
<ArneBab_>it is used in practice
<ArneBab_>yes
<amz3>?
<ArneBab_>installing takes just 5 min → might just give it a shot (use opennet = unsafe mode)
<ArneBab_> https://freenetproject.org/
<ArneBab_>sadly the only packages are for Gentoo and Arch…
<ArneBab_>(the debian one isn’t up to date enough to connect)
<amz3>I got it :)
<rekado>davexunit: I just cloned the sly repo and built it. I'll read the docs next. Hope this can be used to get me closer to my first real game (unlike those I wrote 20+ years ago in QBasic) :)
<rekado>reading the manuals for guile-opengl and guile-sdl first.
<rekado>davexunit: there's a typo in the "Introduction" section. "input even handling" --> "event".
<davexunit>ACTION facepalsm
<davexunit>facepalms, even.
<davexunit>thanks rekado