IRC channel logs

2015-03-10.log

back to list of logs

<Zuchto>When embedding guile; is it possible to create multiple guile contexts for execution such that variables defined with set! and define does not leak between them?
<mark_weaver>Zuchto: sounds like a good use for the module system.
<Zuchto>What I want to do is be able to load a bunch of scripts that each has functions to manipulate some data that is passed to it and I want to iterate over a list of these scripts calling different functions with different data without having to care about scripts defining the same functions.
<Zuchto>would that be doable with modules?
<Zuchto>and I want these scripts to have access to functions defined by the C-code that calls the script
<mark_weaver>create a module for each script, have that module import some central module with the bindings you want them to have access to.
<mark_weaver>sorry, I have to go afk now.
<Zuchto>mark_weaver: thanks!
<nalaginrut>morning guilers~
<adhoc>afternoon nalaginrut
<nalaginrut>adhoc: heya
<adhoc>i recently purchased "the little schemer"
<adhoc>i started reading it before work got really busy
<adhoc>now my wife started reading it
<adhoc>and she is further ahead than i am!
<adhoc>she has never programmed before!
<nalaginrut>oh, as I know, nowadays many many women are trying to program, as a hobbit, and doing well
<adhoc>even hobbits are learning to program?
<adhoc>i tried to teach my wife Perl a few years ago, but that didn't "stick".
<adhoc>she just never really got the hang of it
<mark_weaver>scheme is a *much* better language for non-programmers to start out with, IMO :)
<adhoc>mark_weaver: all the paranthese are cuasing some issues
<please_help>Scheme is the best language for everything (except kernel programming), prove me wrong ;^)
<mark_weaver>nah, I wouldn't use it to write a video codec :)
<adhoc>a compiled scheme with the same kind of compiler optimizations would be fine =)
<mark_weaver>scheme is a much harder language to optimize than C
<adhoc>mark_weaver: no doubt. macros do my head in for that sort of thing, becuase you still need an interpreter/compiler at run time.
<adhoc>that one thing alone continues to bite me in a REPL
<nalaginrut>please_help: I really want to prove you wrong ;-D
<adhoc>nalaginrut: or prove please_help right =)
<please_help>;)
<please_help>Are the functional pseudo-guarantees not useful enough compared to the optimizations possible in side-effect-prone languages?
<adhoc>please_help: i am still learning scheme. so not really a native scheme thinker in that regard.
<nalaginrut>IMHO, a system written in FP is largely concerned about reliability rather than performance
<nalaginrut>although I wish Scheme could be very fast too...
<mark_weaver>please_help: one inherent complication is the existence of first-class continuations. another issue (addressed in R6RS but not yet in Guile for various reasons) is the fact that all top-level bindings are mutable. and finally, a large part of the issue is the way we tend to write programs in Scheme.
<wleslie>while it's possible to get around these, the mechanisms you might introduce get in the way of truly modular compilation.
<mbuf>does guile have support for multi-core systems, or can it take advantage of multiple processors?
<wleslie>it's free threaded
<wleslie>long time no see mbuf (:
<mbuf>wleslie, so we create multiple processes?
<wleslie> not usually, no
<wleslie>but you can do that if you want
<mbuf>I am just reading on running Emacs with the Guile interpreter and what the difference is
<wleslie>guile has effectively the same threading support as C
<wleslie>while you can fork if you want, you're supposed to do this before starting extra threads, because of posix weirdness
<nalaginrut>mbuf: I think there're fork/pthread/futures for you ;-)
<mbuf>wleslie, okay
***michel_mno_afk is now known as michel_mno
<ArneBab>please_help: you want me to write a kernel? ☺
<ArneBab>mark_weaver: what do you mean with “the way we tend to write programs in scheme”?
<ArneBab>(as problem for speed)
***wleslie is now known as Congrammer
***Congrammer is now known as Cogrammer
***Cogrammer is now known as wleslie
<{0}grant>ArneBab: There was at one point, a way to extend Linux in some variant of Scheme. I can't recall the name right now though.
<ArneBab>wow…
<ArneBab>why did it disappear?
<{0}grant>ArneBab: I'm assuming lack of interest from the greater Linux community, and not keeping upstream.
<ArneBab>that sounds plausible, yes…
<{0}grant>Well, duckduckgo'n and googling something along the lines of "extending linux kernel in scheme lisp" isn't turning anything up. :^/
<{0}grant>Not sure of the general utlitly would be compared to just extending something with the intention by design to be modularized to potientally do such a thing though -- just like about any microkernel.
<{0}grant>ArneBab: Yeah, sorry, giving up on the search. Maybe I'll look somemore tomorrow after school ... I'm supposed to be sleeping now though, so I'm going to be smart about it. o/
<ArneBab>oh… thank you for looking
<ArneBab>{0}grant: good night!
<ArneBab>(my day just began ☺)
***michel_mno is now known as michel_mno_afk
<wingo>moin
***michel_mno_afk is now known as michel_mno
<ArneBab>moin wingo
***michel_mno is now known as michel_mno_afk
***michel_mno_afk is now known as michel_mno
<civodul>Hello Guilers!
<Zuchto>Just curious; is there any significant overhead when dealing with modules in guile? My plan is embed guile and create modules, loading scripts in those modules and then switching between modules calling different functions to deal with incoming messages.
<Zuchto>(creating modules with the C-api that is
<Zuchto>)
<wleslie>sounds like a class
<Zuchto>a class?
<wleslie>a goops class
<davexunit>Zuchto: I don't know of any performance issues caused by the module system.
<davexunit>everything uses the module system, so I'd recommend creating modules to compartmentalize your code.
<Zuchto>well, I want the script to be "reasonably" sandboxed so that it can keep states easily with things like define and set!... just to make the scripting as easy as possible
<Zuchto>davexunit: nice :)
<davexunit>that sounds like a bit of an abuse of what modules are for.
<Zuchto>davexunit: but there are no other ways to create separated top-levels in guile without actually forking different processes, no?
<davexunit>I guess I don't understand why you want a bunch of mutable global state
<davexunit>so much so that you want to separate them with modules.
<Zuchto>davexunit: I want each script to be as stripped down as possible. I don't want them to have to declare a class and then risk someone writing a script to use define and it clashing with some other script.
<Zuchto>basically I just want each script to declare a function
<Zuchto>(with a specific prototype)
<davexunit>well, for one thing you don't have to use classes at all.
<davexunit>there's an OOP extension for Guile, but it's not a mandatory thing.
<Zuchto>ok, so the setup is this: the process will receive a message, in a directory there will be a bunch of scripts, each script defines a handle-message function, the incoming message will be passed through each handle-message in order, independentaly of how many scripts the user has added, and then it will send a message out as the last handle-message returns. How would you, davexunit, recommend that I do that
<Zuchto>without modules?
<ArneBab>modules and classes are a different thing in guile
<dsmith-work>Morning Greetings, Guilers
<ArneBab>moin dsmith-work
<wleslie>morning dsmith-work!
<ArneBab>Zuchto: I’ll have to test before I say something concrete, though.
<davexunit>Zuchto: I don't think a directory full of "scripts" is a great architecture.
<Zuchto>ArneBab: yes, I am aware
<ArneBab>davexunit: how would you implement userscripts?
<ArneBab>davexunit: in a way which is as easy as possible for the user?
<davexunit>add guile modules to the load path
<ArneBab>I’d think that that’s not excluding each other
<davexunit>ArneBab: it seems that this isn't a simple user script like init.el in emacs
<davexunit>there's a program that is processing messages, and when it gets a message it loads some guile source code files from disk?
<ArneBab>Zuchto: my first question would be how you define the oder
<davexunit>it's very strange and inefficient
<davexunit>those "scripts" should be modules, and they should have a procedure that gets registered to handle whatever event is needed.
<ArneBab>davexunit: I’d guess it would do something like “((@ (package module) handle-MSGTYPE) msg)”
<davexunit>and then there's the idea of using the module system to handle a bunch of global state, which makes me suspicious.
<ArneBab>Zuchto: please excuse that I’m guessing…
<ArneBab>davexunit: I’d guess that the global state means that the script should be free to do whatever its programmer deems sane.
<ArneBab>(or necessary)
<Zuchto>ArneBab: either [0-9]+-(\\S+).scm as in udev/rules.d or possbily just keep a user-defined ordering of the scripts
<ArneBab>Zuchto: so you want your program to read the folder to get the scripts, so users only need to drop new scripts in there?
<Zuchto>ArneBab: exactly
<davexunit>sure, but there's also the detail of creating modules via the C API
<ArneBab>(without having to modify anything)
<davexunit>that also seems real fishy
<Zuchto>davexunit: that was just my idea to minimize boilerplate
<ArneBab>davexunit: I’d guess it’s an idea for an implementation detail which could easily change.
<davexunit>I don't think it's boilerplate
<ArneBab>Zuchto: so, to get to the gist, you want to define a scripting API which simply says “write a file named [0-9]+-(\\S+).scm which exports handle-GET with the argument msg. That function will be called for the message”. Is that about it?
<Zuchto>my ideal would be to just have a file containg (defun handle-msgtype (msg emit) (emit msg)) as a NOP handler
<ArneBab>Zuchto: to completely separate the scripts from each other (as long as they keep their hands out of the module system)
<Zuchto>ArneBab: yeah, that is about it
<Zuchto>But of course, if there are reasons against this approach then I'm totally open for other suggestions.
<ArneBab>Zuchto: I guess you could do something like this: (module-for-each (λ (x y) (write x)(newline)) (resolve-module '(srfi)))
<ArneBab>(that’s unordered, though)
<Zuchto>ArneBab: what would I even use that for? Feel like I'm missing tons of context for being able to interpret that comment
<ArneBab>Zuchto: that gives you all the submodules within a directory (in this case the directory srfi)
<Zuchto>ArneBab: and then each script would be defined as a module?
<ArneBab>yes
<ArneBab>the minimal script would be (define-module (yourprog modulename) #:export (handle-MSGTYPE))(define (handle-MSGTYPE msg emit)(emit msg))
<ArneBab>Zuchto: this way users could have multiple directories where they could put their modules (one systemwide, one per user, maybe even one per process)
<ArneBab>Zuchto: and in your program you wouldn’t worry where the module might be stored, but just call the handle-functions
<Zuchto>ok :) thanks for the input!
<ArneBab>Zuchto: mind though that I am no Scheme expert.
<ArneBab>Zuchto: I’m still deep in the learning-phase
<ArneBab>(learning basics)
<Zuchto>:)
<ArneBab>todays pretty useful guile hack: $(foreach x,$(shell for x in {1..$(words $(ADDITIONAL_PDFLATEX_DEPENDENCIES))}; do echo $$x; done),sed -i "s/$(word $(x),$(ADDITIONAL_PDFLATEX_DEPENDENCIES))/fig$(guile (format "~2'0d" (string->number "$(x)")))$(suffix $(word $(x),$(ADDITIONAL_PDFLATEX_DEPENDENCIES)))/" $@; cp "$(word $(x),$(ADDITIONAL_PDFLATEX_DEPENDENCIES))" "fig$(guile (format "~2'0d" (string->number "$(x)")))$(suffix $(word $(x),
<ArneBab>$(ADDITIONAL_PDFLATEX_DEPENDENCIES)))"; )
<ArneBab>(using guile format to rename image files to get ready for ACP submission)
<dsmith-work>ArneBab: Is that shelling out to guile, or using guile as a make builtin? (I'm assuming that's make)
<ArneBab>it’s make
<dsmith-work>And $(guile ...) is a builtin?
<mark_weaver>I agree with what davexunit wrote
<ArneBab>dsmith-work: yes :)
<mark_weaver>(to Zuchto)
<ArneBab>I’m sure I’m still doing it in a much too complicated way, but it’s still very useful (I must name the images fig##.ext, with ## starting with 0 for numbers smaller than 10.
<ArneBab>mark_weaver: how would you do a module system?
<ArneBab>mark_weaver:
<ArneBab>mark_weaver: with the requirement: Files which can just be dropped into place
<mark_weaver>I only have one free hand right now, so this will have to wait until later
<mark_weaver>ArneBab: I believe your module-for-each thing will only find modules that have already been loaded
<ArneBab>mark_weaver: that wouldn’t work, then. I also saw (module-modified m): does that mean that guile could check constantly whether the user added a module and reload it instantly?
<mark_weaver>and even that won't work unless deprecated mode is enabled
<mark_weaver>I don't know
<mark_weaver>but please don't assume that any undocumented behavior you discover in today's guile will work in the future
<mark_weaver>or that some undocumented procedure you find in the guts of guile will always remain
<please_help>I want to define procedures array-first and array-rest. These must work on arbitrary-rank arrays. Moreover, they must "skip over" the last K dimensions (e.g. (array-first K=1 array=#2f32((1 2) (3 4))) ;=> (1 2). If K=0, the answer would be 1.
<please_help>Array-rest must be a complement of array-first, given the same arguments.
<please_help>My problem is that I don't know how to do the array-rest without knowing in advance which index must be skipped over.
<please_help>is it enough to just +1 on the K'th index? I think not, but I'm too tired to think about it, hoping fresh heads can help here.
<ArneBab>mark_weaver:
<ArneBab>mark_weaver:
<ArneBab>mark_weaver: ok, thanks for the warning
<ArneBab>(sorry for the triple-highlight: I hit enter by accident)
<davexunit> https://twitter.com/ID_AA_Carmack/status/575339970380062721
<davexunit>"I am seriously considering pushing s-expression data and an embedded Scheme for a VR experience file format." - John Carmack
<mark_weaver>nice!
<please_help>Year of the lin- scheme mainstream language?
<davexunit>John Carmack talks about Scheme from time to time, has mostly good things to say, but then also says that he wouldn't use it for anything serious because it's not statically typed.
<davexunit>it's interesting to see him discover Lisp and Haskell only recently, he's had a very long and successful career writing C/C++.
***michel_mno is now known as michel_mno_afk
<wingo>ahoy
<dsmith-work>wingo: Hey hey
<wingo>ahoy :)
<unknown_lamer> https://twitter.com/ID_AA_Carmack/status/575339970380062721
<ft>I think I'm going to play a bit of quake, just for that. :)
<dsmith-work>unknown_lamer: Yeah, yeah. Heard it before. And Scheme was going to be the Gnome scriptign glue, and DSSSL was going to use a FP subset of Scheme for stylesheets, and... and...
<dsmith-work>unknown_lamer: ;^)
<unknown_lamer>I thought carmack was into haskell
<dsmith-work>unknown_lamer: http://en.wikipedia.org/wiki/EDIF
***{0}grant` is now known as {0}grant