IRC channel logs


back to list of logs

<str1ngs>hello, is it possible to dynamically rename a goops slot? I have a slot naming conflict and I'm not the creator of the base class.
<RhodiumToad>you want to rename it in the base class rather than your derived class?
<str1ngs>preferable in the derived class.
<str1ngs>the bass class is in a library and I'd like to not touch it if possible.
<str1ngs>sorry I mean I'd like to possible rename it in the base class but dynamically
<str1ngs>I hope that made sense
<str1ngs>I'm thinking that's not a good idea. since it would break the libraries methods.
<RhodiumToad>yeah, it seems like an implausible idea
<dsmith>On the other hand, two different labels for the same memory location seems doable.
<dsmith-work>Happy Friday, Guilers!!
<civodul>Happy Friday & Happy Free Software Valentine's Day! :-)
<mwette>same to you'all
*mwette is cleaning up nyacc configure to install/work w/ guix
<rlb>(I recently noticed too.)
<shader>how do I figure out what all of the existing reader macro definitions are? E.g., all the default uses of the '#' character?
<shader>I'm looking for a section in the manual, but I haven't found it
<dsmith-work>shader: I think you can get at the ones added using read-hash-extend by (fluid-ref %read-hash-procedures)
<dsmith-work>But I don't think there is a way for "builtins", like #t and #\
<dsmith-work>Maybe by digging into the reader sources?
<rotty>anyone aware of someone having packaged Alex Shinn's `fmt` library for Guile (
<dustyweb>hello #guile
<dustyweb>rotty: I know of it but haven't gotten to try it yet
<dustyweb>I adore Alex's irregex package though
*rotty is torn between updating his "wak" suite of R6RS libraries, and just "vendoring" stuff for a small project
<rotty>yeah, he produces excellent stuff. chibi-scheme is also a pearl of C code, IMHO
<rotty>(just in case anyone is wondering, "wak" is at
<weinholt>please do update wak. :) i use wak-fmt in akku, where it is also packaged:
*rotty opens a beer, as he would have never suspected there are still people making use of this stuff, after it laying dormant for almost a decade
<rotty>weinholt: ok, I have dropped out of Scheme development for a bunch of years now (time flies) -- I'm kinda curious how well dorodango and wak have aged (or rather, how much they have bitrotted)
<weinholt>"That is not dead which can eternal lie. And with strange aeons even death may die."
<weinholt>wak is holding up pretty well, but some have newer upstream versiosn
<weinholt>dorodango is... not well
<sviteri>Hello, is it possible to extend the conditions of match statement after it has been defined?
<sviteri>Suppose I have the following toy programming language:
<sviteri>(define (step prog)
<sviteri> (match prog
<sviteri> (('I x) x)
<sviteri> ((('K x) y) x)
<sviteri> (((('S x) y) z) `((,x ,z) (,y ,z)))
<sviteri> (x x)))
<daviid>rotty: wow, nice to 'see you' here :) fwiw, the gitlab link you posted above redirect to a login
<sviteri>And then later I synthize a new piece that want to add to my language
<rotty>daviid: thanks :) I just checked in a private firefox window, and i get a project listing at
<daviid>rotty: ah ok, sorry! i think my (ver basic, low cost) mouse is tricking me (by registering several click for one ...)
<daviid>i see it now
<daviid>rotty: i just posted a quiz on #introspecton, if you have a min to read it, i bet you know the answer :)
<sviteri>Here is an example:
<sviteri>scheme@(guile-user)> (program-to-reduction-rule '(S I))
<sviteri>$3 = ((((S I) v0) v1) (v1 (v0 v1)))
<RhodiumToad>given that match is a macro which compiles to expressions specific to the patterns it matches, the answer is basically no, not without recreating the function
<sviteri>right, I believe that
<sviteri>I have also tried to redefine step in a way that does not bind free variables:
<sviteri>(define (step' prog)
<sviteri> (cond
<sviteri> ((and (pair? prog) (eq? (car prog) 'I)) (cadr prog))
<sviteri> ((and (pair? (car prog)) (eq? (caar prog) 'K)) (cadar prog))
<sviteri> ((and (pair? (caar prog)) (eq? (caaar prog) 'S))
<sviteri> `((,(cadaar prog) ,(cadr prog))
<sviteri> (,(cadar prog) ,(cadr prog))))
<sviteri> (else prog)))
<sviteri>But it is not nearly as simple to generate a new reduction rule in this form (or as elegant)
<sviteri>Are there any clear solutions here that I am missing?
<RhodiumToad>well, recreating the function on the fly is not outside the bounds of possibility
<sviteri>Yes, this is what I mean
<sviteri>Creating a new match statement with the new piece is fine
<sviteri>But a naive attempt to do this breaks
<RhodiumToad>what did you try?
<sviteri>scheme@(guile-user)> (program-to-reduction-rule '(S I))
<sviteri>$10 = ((((S I) v0) v1) (v1 (v0 v1)))
<sviteri>scheme@(guile-user)> (match '(((S I) X) Y) `(,(program-to-reduction-rule '(S I))))
<sviteri>While compiling expression:
<sviteri>Syntax error:
<sviteri>unknown file:340:23: unquote: expression not valid outside of quasiquote in form (unquote (program-to-reduction-rule (quote (S I))))
<sviteri>I tried a match statement with only the generated rule
<stis>rackets macther is extensible and available for guile if that is what you are after
<stis>err extendible it should be
<stis>sviteri: ^^
<sviteri>Thanks <stis> looking into it now
<RhodiumToad>the problem is not extending match itself, but extending a constructed match expression
<sviteri>My guess at the issue is that match takes variables and binds them, like lambda
<sviteri>What I am feeding it makes about as much sense as feeding a symbol to a lambda binding:
<stis>you want the matcher to be a datastructure?
<sviteri>not sure what you mean
<RhodiumToad>how about something like this:
<RhodiumToad>(define lang '[(('I x) x) ((('K x) y) x)])
<stis>m1 = (list 'a 'b 'c) m2 = (cons 'u m1) and use a function binding-assoc = (match m2 data)
<RhodiumToad>then (compile `(lambda (prog) (match prog ,@lang)) #:env (current-module))
<stis>macros is possible as well I think
<stis>in stead of a compile
<RhodiumToad>a macro by definition can't help you if you want to add new cases without recompiling
<sviteri>@RhodiumToad what does compilation buy me here
<stis>aha like a prolog dynamic predicate but more fundamental?
<sviteri>let me see if I can use <RhodiumToad>'s method with a generated addition to the lang
<RhodiumToad>the result of the (compile) is a procedure value that you then apply to your program
<sviteri>scheme@(guile-user)> (define lang `[,(program-to-reduction-rule '(S I))])
<sviteri>scheme@(guile-user)> (define s (compile `(lambda (prog) (match prog ,@lang)) #:env
<sviteri> (current-module)))
<sviteri>scheme@(guile-user)> (s '(((S I) X) Y))
<sviteri>ERROR: Wrong type to apply: X
<RhodiumToad>what's the result of program-to-reduction-rule there?
<sviteri>scheme@(guile-user)> (program-to-reduction-rule '(S I))
<sviteri>$21 = ((((S I) v0) v1) (v1 (v0 v1)))
<sviteri>All symbols
<sviteri>Oh wrong parens let me try again
<sviteri>Does [] differ from ()
<RhodiumToad>match needs it to be (((('S 'I) v0 ... I think
<RhodiumToad>to distinguish literals from bindings
<sviteri>scheme@(guile-user)> (define lang (program-to-reduction-rule '(S I)))
<sviteri>scheme@(guile-user)> lang
<sviteri>$22 = ((((S I) v0) v1) (v1 (v0 v1)))
<sviteri>scheme@(guile-user)> (define s (compile `(lambda (prog) (match prog ,@lang)) #:env
<sviteri> (current-module)))
<sviteri>scheme@(guile-user)> (s '(((S I) X) Y))
<sviteri>ERROR: In procedure module-lookup: Unbound variable: v1
<sviteri>Only difference here is that I had extra parens in the definition of lang
<sviteri>Right I need to distinguish literals from bindings
<sviteri>This is the crux of the issue
<sviteri>So what do I make v0 and v1 if not symbols? Since they are coming from the outside, I do have to define them
<RhodiumToad>they're not coming from outside
<sviteri>stis what is the 'u in your example
<sviteri>RhodiumToad: what do you mean
<RhodiumToad>so the main issue here is that your (v1 (v0 v1)) in the result of that match looks like a Scheme function application
<RhodiumToad>and X isn't a function, so when v1 is bound to X and that form evaluated, you get an error
<sviteri>Hmm, then why isn't the error about a bad application?
<RhodiumToad>basically, your program-to-reduction-rule isn't yet generating the right syntax to use in a (match) clause
<sviteri>scheme@(guile-user)> ('v1 'v0)
<sviteri>ERROR: Wrong type to apply: v1
<sviteri>For sure
<stis>This is a simple exampleif you assume symbols are matcher varibales and the output of the matcher is the bindings in a assoc or #f id not match, then everything is all functional and you can make the matcher how dynamic yoou like and build abstarction and higher order toolboxes to assembler the overall function
<stis>but usually when I have a lang that ruduces e.g. code I use macros
<RhodiumToad>if I do (define lang '[((('S 'I) v0) v1) `(,v1 (,v0 ,v1))])
<RhodiumToad>then compile with that, I can do
<RhodiumToad>scheme@(guile-user)> ($14 '(((S I) X) Y))
<RhodiumToad>$15 = (Y (X Y))
<RhodiumToad>er sorry
<RhodiumToad>(define lang '[(((('S 'I) v0) v1) `(,v1 (,v0 ,v1)))])
<RhodiumToad>here lang is [clause clause...] where clause is (pattern expression) hence the extra parens
<sviteri>Can't you get rid of the ,@ if you don't include the extra parens
<sviteri>Or am I misinterpretting something here
<RhodiumToad>match expects (match value clause clause...)
<RhodiumToad>so you need the ,@ if you have multiple clauses
<sviteri>stis: hmm, I'mm trying to understand what you are saying. Also I do have a version of step that is a macro. Not sure what do with it though
<sviteri>Right RhodiumToad, thanks
<sviteri>Let me try to modify my function to output something like your lang example here
<RhodiumToad>basically in the pattern part you need to use symbols for local bindings, and (quote symbol) for symbols to literally match in the input
<RhodiumToad>so ('I x) will match (I foo) and bind x to 'foo
<RhodiumToad>then the result part should either be a single bound variable, or a `(...) form
<sviteri>is there a way to recursively unquote
<sviteri>I have something in the form '(v1 (v0 v1))
<sviteri>If I am understanding correctly I need something of the form `(,v1 (,v0 ,v1))
<sviteri>If I try to evaluate the form I get an error from unbound variable v1
<RhodiumToad>so basically you want all symbols to be ,sym unless they are (quote sym) which just becomes sym ?
<RhodiumToad>so that e.g. (I a) becomes `(I ,a) ?
<sviteri>stis: I read it again and understand the code you provided
<RhodiumToad>I mean ('I a) becomes `(I ,a)
<sviteri>I think that ends up in the same issue we are discussing now
<stis>yep, i bit more modular but very similar
<sviteri>Ok, trying again
<sviteri>Let me show you my attempt here, thanks for your patience both of you
<sviteri>(define (program-to-reduction-rule prog)
<sviteri> (match-let (((conc . count) (concretize-and-count prog)))
<sviteri> (let ((vars (map (lambda (x) (string->symbol (string-append "v" x)))
<sviteri> (map number->string (iota count)))))
<sviteri> `(,(apply-individually prog vars) ,conc))))
<sviteri>The only important detail is what lives in conc
<sviteri>scheme@(guile-user)> (concretize-and-count '(S I))
<sviteri>$25 = ((v1 (v0 v1)) . 2)
<sviteri>This function takes a program and generates its reduction rule
<sviteri>the apply-individually stuff just generates (((S I) v0) v1), or the left side of the match rule
<sviteri>I believe what I need to do to match is wrap S and I in 'quote' and nothing else
<sviteri>Is this correct?
<stis>yep the compile method should work ok, but comiling i slow, mey be fast enough - depends on circumstanses
<sviteri>This piece of the code is speed critical, but I don't want to worry about that at this moment
<stis>good, if you want ideas to improve the speed you cna come back if you like
<sviteri>I appreciate it
<stis>sometimes the reduction is computer intensive and the compiling is a boon.
<stis>sometimes not
<stis>not sure if it has been bitrotted
<sviteri>Is there a description somewhere
<stis>see the readme
<stis>another option is to eval the expression in stead of compiling, getäs you some speed but still you will need to macroexpand a complex macro
<sviteri>umm how do I get to the code
<stis>do get to the project? or is it a private repo?
<sviteri>I can't seem to view the code directly from the link provided
<stis>if you get the project page, then clice ice-9
<stis>click ice-9
<sviteri>yep don't see anything
<sviteri>like ice-9
<sviteri>Full disclosure haven't used gitlab, so maybe I'm missing something obvious
<stis>can you reach
<stis>darn the repo is private, ok I have to make it public
<sviteri>What is the idea of this?
<sviteri>It is a matcher that is meant to be extra fast
<sviteri>or extra dynamic
<stis>(define m1 (prepend-imatch '(1 2) (lambda () 'a) imatch-null))
<stis>(define m2 (append-imatch '(?a 2) (lambda (?a) (list 'b ?a)) m1))
<stis> > (imatch '(1 2) m2)
<stis> 'a
<stis> > (imatch '(9 2) m2)
<stis> '(b 9)
<stis>?a is variable all else is literals
<sviteri>RhodiumToad: I am having trouble getting this to work right now. But am I correct that your hypothesis is that there is a way to get the symbols to work as match variables without any fancy machinery?
<RhodiumToad>which symbols?
<sviteri>these ones
<sviteri>scheme@(guile-user)> (program-to-reduction-rule '(S I))
<sviteri>$27 = ((((S I) v0) v1) (v1 (v0 v1)))
<sviteri>All of these are symbols right now
<RhodiumToad>right, and you need to distinguish which ones are supposed to be literals and which variables
<sviteri>And the way to distinguish is to unquote?
<RhodiumToad>if you transform that to (((('S 'I) v0) v1) `(,v1 (,v0 ,v1))) then it will work
<RhodiumToad>on the left side, quote the literals and leave the variables unquoted. on the right side, unquote the variables and leave any literals as plain symbols (and quasiquote the whole thing)
<RhodiumToad>that's the form that match expects to work with.
<stis>can someone read this page?
<RhodiumToad>I get a not-found error
<stis>can you read the readme of this one? see files?
<RhodiumToad>where would the readme be?
<RhodiumToad>I get a project page with "No activities found"
<stis>directly at the bottom of that page
<RhodiumToad>nope, I don't see that
<sviteri>same as RhodiumToad
<stis>okey, you do you see a clone button? you shoulj be able to clone a git repo from it
<stis>inside there is a readme
<RhodiumToad>nops, no clone button
<RhodiumToad>note that I'm not signed in
<RhodiumToad>there's a star button that requires that you sign in, no other controls
<sviteri>So there is a difference between written and printed forms of the same term
<stis>ahh, toggling the visibility back and forth helped
<stis>no try again
<RhodiumToad>aha, now I see a repo
<sviteri>so if I have
<RhodiumToad>and e.g. shows me some code
<sviteri>scheme@(guile-user)> (program-to-reduction-rule '(S I))
<sviteri>$27 = ((((S I) v0) v1) (v1 (v0 v1)))
<sviteri>I really have a term that is (((('S 'I) 'v0) 'v1) ('v1 ('v0 'v1)))
<RhodiumToad>to read that back in you'd use '((((S I) v0) v1) (v1 (v0 v1)))
<stis>quites for S and I ?
<sviteri>Right because I just wrote a bunch of applications
<RhodiumToad>'(A B) evaluates to a value which is a list of two symbols, whereas (A B) evaluates as an application of A to B
<sviteri>but then
<sviteri>(((('S 'I) v0) v1) `(,v1 (,v0 ,v1)))
<sviteri>is an application of symbols
<RhodiumToad>the match macro expects (match value clause clause...) where each clause is (pattern expression) where pattern is not evaluated, but expression is
<stis>actually it is (pattern expr ...) there is an implicit begin
<sviteri>so the ('S 'I) isn't a problem because it isn't evaluated because it is in the pattern
<RhodiumToad>in the pattern part, match itself distinguishes between a symbol, which matches anything and binds the matched value, and (quote symbol) which matches the literal symbol
<sviteri>I just need to get it there is that form without evaluating
<sviteri>*there in that form without evaluating it
<RhodiumToad>to explain using a simpler example,
***jonsger1 is now known as jonsger
<RhodiumToad>(match x (('I a) a)) means that if x has the form (I anything) then the result is whatever the "anything" is
<RhodiumToad>(match x (('I a) `(J ,a))) means that if x has the form (I anything) then the result is (J anything)
<RhodiumToad>btw it's not possible to just take ((((S I) v0) v1) (v1 (v0 v1))) and convert it to what you need without knowing externally that S and I are supposed to be literal symbols
<RhodiumToad>if you have, say, a list of what symbols are literals, you could assume anything else is a binding
<rotty>weinholt: you are right; dorodango is broken on both Guile and Racket (which was to be expected). I at least now restored its former home page originally hosted on
<rotty>the thing is, i kinda want to get dorodango working before trying to update wak; I'll keep you posted
<sviteri>So in the process of creating the pattern itself, I end up doing illegal applications
<sviteri>such as ('I a)
<RhodiumToad>that's only illegal if you try and evaluate it
<sviteri>But maybe if I created the pattern using a macro instead of a definition I wouldn't run in to this problem
<dsmith-work>rotty: Since you are back in the Scheme of things, any chance on getting your irc logger and web interface to them working again?
<dsmith-work>rotty: It was really nice!
<RhodiumToad>I guess the downside of having a language that uses the same representations for code and data is that it gets confusing to keep track of when your code is actually data
<dsmith-work>Searchable, and you could hide "noise" (joins and such)
<sviteri>Maybe, but maybe I just need to be better
<dsmith-work>rotty: If not, it's ok.
<sviteri>Can I create the pattern as a list
<RhodiumToad>how are you creating it right now?
<sviteri>As a list
<sviteri>(define (apply-individually f args)
<sviteri> (define (apply-individually-aux f args)
<sviteri> (if (eq? 1 (length args))
<sviteri> `(,f ,(car args))
<sviteri> `(,(apply-individually-aux f (cdr args)) ,(car args))))
<sviteri> (apply-individually-aux f (reverse args)))
<sviteri>(apply-individually 'S '(X Y Z))
<sviteri>;$40 = (((S X) Y) Z)
<sviteri>So I need to quote the S
<stis>tyr `(',f ,(car args))
<RhodiumToad>I would do it earlier