IRC channel logs
2023-10-30.log
back to list of logs
<ArneBab>The pure Scheme one will be almost the same. No : for "result of logic", and all examples transformed via wisp2lisp. <ArneBab>It includes a few SRFIs: srfi-9 (records), srfi-64 (tests) and srfi-26 (cut). I consider these essential for efficient work with Scheme. <ArneBab>Also I’d love to get my doctests code into Guile proper, because that has proven to be extremely valuable for me. <ArneBab>I think that writing this actually improved my understanding of Scheme on a conceptual level. For example that all the quasiquote and unquote[-splicing] forms its own part with symbols which I hadn’t seen clearly before. The term "symbolic computation" suddenly made more sense :-) <apteryx>macro question: I have an enum set defined like: (define-enumeration log-level (debug info warning error) make-log-level) at the top level <apteryx>I want to loop its symbols, which I can access with this: (map symbol->string (enum-set->list (enum-set-universe (make-log-level)))) to define convenience procedures such as (define (log-debug args) (apply log-msg (cons 'debug args))) <apteryx>what should I use to do that? I need syntax-case, right? <apteryx>I guess I'll use syntax-case to wrap-in the definition of the enum at the same time; it'll transform the log levels into the enum and the various log-%level convenience procedures. <haugh>arnebab, where is your doctest implementation? I'm doing a simple one on SRFI-64 and I would much rather just stop and use something decent :) <apteryx>it allows configuring the log levels as an enum, and creates convenience 'log-debug', 'log-info', etc. procedures to log for each level. <flatwhatson>apteryx: won't (car levels) on line 59 error when levels is null? <apteryx>it would if this happened, but I don't see how it could? <apteryx>since the level argument is an enum, unless of a programming error you are guaranteed to hit a level once, avoiding the (car '()) case <apteryx>the possible levels are (debug info warning error) <flatwhatson>ah, loop call is conditional inside the unless. don't mind me :) <apteryx>I'll try to use this in a couple projects, and if it turns useful I'll consider adding the useful bits to the logging library of guile-lib <apteryx>I guess having %default-setup-logging and %default-shutdown-logging procedures could be useful for most basic setups, as well as having the define-log-level macro. <daviid>apteryx: fwiw, i am not too entousiast by that idea - for one thing, it uses goops, so i would prefer to add, if necessary, an <enum> class and methods, not using this (not very good imo) enumeration 'scheme' lib (g-golf has one, constructive critics welcome) - and i also would prefer to add a goops approach to these default functionality wrt log levels you wish to add, rather then using macro - my few cents <daviid>imo, if we improve the logger lib, we should do so keeping as close as possible to the the 'original' programming style - using goops and if necessary, the mop, and avoid macros <attila_lendvai>daviid, random 0.02 re logging: i think it's a key feature to also have a compile-time log-level that can reduce the log lines to (values) when turned low enough <dthompson>it uses guile-hoot to compile scheme to webassembly so it's playable in a web browser (a new one, anyway) <apteryx>daviid: I see, thanks for your input <apteryx>daviid: it seemed natural to me to use (rnrs enums) rather than try to reinvent <enum> <apteryx>but I do agree it's a bit unintuitive to work with (but I don't think it matters much here; the API to configure the logger would be limitited to using define-log-level (with a well documented example it'd be clear), make-log-level and the various log-$level procedures it binds <apteryx>*unintuitive to work with (rnrs enums), at least when you are getting to know them <ArneBab>haugh: my doctests are something I built up for myself in my wisp examples, but postponed making it standalone again and again. There are quite a few things I should contribute to some library (i.e. guilelib). <ArneBab>apteryx: there is string-downcase and string-downcase! <ArneBab>dthompson: but it does not take my actual keyboard into account (via xmodmap). Instead it uses the untranslated keystrokes. <ArneBab>dthompson: or something like this — I can’t seem to reliably hit enter. <dthompson>ArneBab: I guess JS keyboard events don't do that... wasn't aware of that. <apteryx>how can I create a 'repeat' switch with guile-config? e.g. -vv -> verbosity level = 2 <ArneBab>dthompson: no reason to feel sorry — it’s not like you could have tested it ☺ <ArneBab>dthompson: normally I would expect the keyboard events to get it right. Which property do you use? There’s "code" which takes the physical key and "key" which actually gets the translated unicode letter. I think only the latter uses my keyboard layout. <apteryx>re guile-config, I can increment a counter incremented the number of times the 'merge-strategy' handler procedure is called <dthompson>so that means... fire is the key to the right of left shift <apteryx>one thing weird with define-enumeration (from (rnrs enums)) is that the constructor is a <apteryx>*is a macro that can't be invoked dynamically <apteryx>e.g. in my case I can't do (make-log-level 'debug) <apteryx>which makes it useless for use with dynamic configuration of an application (command line switches) <dthompson>apteryx: bummer that it doesn't have identifier syntax to generate a procedure in that case <daviid>apteryx: what i am trying to share with you, is you can acheive a (much imo) cleaner similar resuslt using goops and its mop if necessary <daviid>like wise wrt to a well design <enum> class, methods and ofc possibly sublass(es), <log-level> or what ever the user would need for their specific 'logger neeeds' ... <daviid>imo it matters a lot to kep the excellent original programming style, unless there would be a good reason no to ofc ... <whartung>The Guile manual under Modules->Processes has a "spawn" procedure to create a new process. But my Guile 3.0.7 doesn't seem to have it. It has other symbols on the same page (such as umask), so I don't think I'm missing a module. Is there a replacement for spawn? <whartung>ah, it seems that spawn is a 3.0.9 feature and thus not in 3.0.7 that would explain it. <haugh>arnebab, thank you for sharing your doctests. I'm trying to separate the point of documentation from the point of definition, mostly to account for all the different ways to define procedures, e.g. curried-definitions, parameters, etc. I also dislike it when a large procedure doc separates the arguments from the body, but that's secondary. <haugh>arnebab, regardless this is a very interesting implementation and I definitely needed some inspiration <haugh>arnebab, does this allow a procedure definition whose body is just one vector literal? <apteryx>it seems our implementation of enum-set-constructor from (rnrs enums) may have a bug: ((enum-set-constructor (make-enumeration '(a b c))) '(d)) -> #<enum-set universe: #<enum-set universe: #0# set: (a b c)> set: (d)> <apteryx>the doc says: returns a new enum-set with the same universe that represents a subset containing the specified symbols. <apteryx>my understanding: since d is not in the enum-set, it should error out <apteryx>nevermind, it works per the output of 'enum-set->list' <apteryx>e.g., (enum-set->list ((enum-set-constructor (make-enumeration '(red green blue))) '(violet))) -> () <apteryx>can we mix srfi-64 tests within the guile test suite? <apteryx>I guess I can imitate the style used to test srfi-64 itself <apteryx>hm, seems I need to add srfi-125, srfi-128 and srfi-178 as prerequisites <daviid>thanks, but no matter what, imo, these approaches will alaways be (largely) inferior to what you can acheive using goops and the mop - <daviid>i don't have the time now, but it would be nice to experiment an srfi-209 'port' to goops :) -