<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>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'm thinking that's not a good idea. since it would break the libraries methods. <dsmith>On the other hand, two different labels for the same memory location seems doable. <civodul>Happy Friday & Happy Free Software Valentine's Day! :-) *mwette is cleaning up nyacc configure to install/work w/ guix <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 #\ <dustyweb>rotty: I know of it but haven't gotten to try it yet *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 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 <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> (((('S x) y) z) `((,x ,z) (,y ,z))) <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 <daviid>rotty: ah ok, sorry! i think my (ver basic, low cost) mouse is tricking me (by registering several click for one ...) <daviid>rotty: i just posted a quiz on #introspecton, if you have a min to read it, i bet you know the answer :) <sviteri>scheme@(guile-user)> (program-to-reduction-rule '(S I)) <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>I have also tried to redefine step in a way that does not bind free variables: <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>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>Creating a new match statement with the new piece is fine <sviteri>But a naive attempt to do this breaks <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>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 <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? <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 <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>scheme@(guile-user)> (s '(((S I) X) Y)) <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>scheme@(guile-user)> (define lang (program-to-reduction-rule '(S I))) <sviteri>$22 = ((((S I) v0) v1) (v1 (v0 v1))) <sviteri>scheme@(guile-user)> (define s (compile `(lambda (prog) (match prog ,@lang)) #:env <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>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>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 <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>(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 <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>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>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 ? <sviteri>stis: I read it again and understand the code you provided <sviteri>I think that ends up in the same issue we are discussing now <stis>yep, i bit more modular but very similar <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>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 <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 <stis>sometimes the reduction is computer intensive and the compiling is a boon. <stis>not sure if it has been bitrotted <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 <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 <sviteri>Full disclosure haven't used gitlab, so maybe I'm missing something obvious <stis>darn the repo is private, ok I have to make it public <sviteri>It is a matcher that is meant to be extra fast <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>?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? <sviteri>scheme@(guile-user)> (program-to-reduction-rule '(S I)) <sviteri>$27 = ((((S I) v0) v1) (v1 (v0 v1))) <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) <stis>directly at the bottom of that page <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>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 <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))) <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>(((('S 'I) v0) v1) `(,v1 (,v0 ,v1))) <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 ***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>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>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? <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 <sviteri> (define (apply-individually-aux f args) <sviteri> `(,(apply-individually-aux f (cdr args)) ,(car args)))) <sviteri> (apply-individually-aux f (reverse args)))