<plattfot>Hi guile users. I got an odd issue. The repl finds a procedure (pipeline) but my module does not. Both are using (ice-9 popen). I wonder if someone might know what's wrong? <plattfot>I figured it out. I'm using guile-hall as the build system. And when running "guix environment -l guix.scm" it was picking up guile-3.0.2 which then was used to build and run my tests. My repl is using guile-3.0.4. Bumping the guile version in my guix.scm to 3.0.4 (guile-3.0-latest) fixed my issue. ***apteryx_ is now known as apteryx
***meow is now known as Guest46629
<holri1>scheme@(guile-user) [14]> (help format) <holri1>on debiab stable, why is there no doc? guile-2.0-doc is installed. <holri1>what is the difference between 'a and "a" ? <ayys>Has anyone implemented a language on guile using the PEG parser? <RhodiumToad>holri1: 'a is (quote a) which results in a symbol, "a" is a string <ayys>RhodiumToad: I'd like to add that 'X is a shorthand for (quote X) <RhodiumToad>(I think you missed the question which I was answering) <RhodiumToad>(the question was "what is the difference between 'a and "a" ?") <holri1>ok thank you. comming from python there and learnig scheme... is there a difference in (let ((x 5)) x) and (let () (define x 5) x) <RhodiumToad>not in that example. (define) is more like letrec than let, in that the body of the definition can refer to itself by name <RhodiumToad>some people prefer local (define) as a matter of style, some don'r <holri1>I would have expected to write (define 'a 1) instead of (define a 1) because according to eval rules a would be evaluated if it is not 'a . But I guess that define is a special form that does not eval its first parameter. correct? <manumanumanu>holri1: (define ... ) has the same semantics as letrec, i.e: (define a ...) (define b ...) can reference eachother. (let ((a 5)) (+ 5 a) is the same as ((lambda (a) (+ 5 a) 5) <manumanumanu>in some schemes (let ...) will produce faster code, but guile is able to optimize letrec (and by extension define) <manumanumanu>(let () (define a 5) a) => ((lambda () (letrec ((a 5)) a))). (let ((a 5)) a) => ((lambda (a) a) 5) <manumanumanu>and, if letrec is implemented as a macro (which I believe it is not in guile), the expansion gets even more involved. The expansion in chibi scheme would be something like: ((lambda () (define a #f) (set! a 5) a)) <manumanumanu>which is why local defines are slower in many schemes: it turns into mutation, which often means boxing, which means slow code. <manumanumanu>In guile 2.2 (??? at least in 2.0) a local define will be slower than a let block. <manumanumanu>yes. I ported a piece of racket code to guile 2.2 a long time ago, and the overhead of defines was more than measurable. <manumanumanu>RhodiumToad: iirc, that is really the point of the letrectification pass of guile (which as a bonus allows for defines in body context) <manumanumanu>anyway, something happened in the 2.9.x releases that made internal defines magically faster. <ArneBab>manumanumanu: thank you for the details on define! <ManDay>I'm back at struggling with debug output of guile. How come that a "warning: possibly unbound variable" is marked with the line of the parent define, and not actually the line in source where the variable is mentioned? <ManDay>I understand that under certain conditions scheme isn't the easiest language to produce stacktraces from, but this is so trivial, even guile should get that right, right? <ManDay>Different subject: What would you recommend for a method to test a library with internals (e.g. test the library and symbols not exported by the library)? <leoprikler>ManDay: location information tends to get optimized away unless you're using the right options <ManDay>leoprikler: I use --debug, what else should I use? <ManDay>that might just be something worth mentioning in the documentation guys... <ManDay>guile has driven me close to insanity with its incomprehensible debugging output for years, and i never heard (or can't recall) having heard of a -O switch <ManDay>I just run guile <my-script>. is that not how one is supposed to use guile? <ManDay>i let guile do the compiling, i thought that's the idea <leoprikler>If you just have mini scripts, doing that is fine. <ManDay>so... how *are* you supposed to use guile correctly then? <ManDay>And, sorry, but isn't that a bit of misleading design? I think it was reasonable of me to assume guile is to be used like that <leoprikler>You'd usually invoke `guild compile -O... -W... -o OFILE FILE` and then invoke guile with GUILE_LOAD_COMPILE_PATH set <ManDay>i don't even know where the documentation for guild is <leoprikler>that way compilation and execution is split into two phases <ManDay>it's crazy that that's how you're supposed to use it <ManDay>As I understand what you have explained, anyone whose use case is "developing" (as in: encountering bugs and debugging) is supposed to do this <leoprikler>It's like Python. You can either build one-line scripts that you barely glance at or huge ass libraries (and anything in between) <leoprikler>Well, by the point you're "developing", you should already have a build system set up. <ManDay>the comparison to python is very far fetched imo. you are telling me using "guile" without "guild" is unsuitable for development. that is not the case with python <ManDay>you're pretty much disqualifying guile as an interpreter and scheme as a scripting language <ManDay>which is fair, but absolutely unexpected <ManDay>a scripting language (python, javascript) is notoriously fully functional without a build system or invoking the compiler explicitly <leoprikler>Using python without setuptools is like asking to be murdered. <leoprikler>You can do it, but the result is likely going to be unpleasant. <leoprikler>Python and Javascript are not in anyway complete without build systems. <leoprikler>Python does ship its own and we all know the story of NPM. <leoprikler>You *can* use all of them just as interpreter, but power lies in the knowledge, when you ought not to. <leoprikler>Also for reference, guild is mentioned in the manual: <ManDay>i very much disagree. for developing code alone, nothing but the python interpreter needs to be invoked <ManDay>well in any way, I'm admittedly not benefining from this debate about python. i can't stand python <ManDay>yes, I've read these 20 lines in the texinfo manual <ManDay>but frankly, this is not how this should be documented. it might have been a mistake on my part to approach the development like this, but it is far from obvious what is the correct way to do it <leoprikler>I'm pretty sure one would use a number of supplementary tools for serious™ Python development. <RhodiumToad>ManDay: fwiw, I see the "possibly unbound variable" error on the form that contains the reference, is that not where you see it? <RhodiumToad>i.e. not at the top level define, but on the innermost containing form <RhodiumToad>I get errors on lines 5,6,7 all pointing to the ( immediately before the unbound var <ManDay>leoprikler: I haven't been using guile (and not guild to compile things explicitly) all this time, because guile very much suggests that's the correct way to do it. It performs the auto-compilation. Just, as we have seen, it doesn't pass on any -O flag. So here is my question: Why can't do guile what it already does (act as the build system), but do it correctly? <ManDay>Correctly, as in: To an extent which is usefull to a programmer <leoprikler>"It doesn't pass any -O flag." Are you sure about that statement? <ManDay>RhodiumToad leoprikler I was not correct. If I compile it as-given, I also get errors on line 6, for example <ManDay>leoprikler: No, I'm not sure. But do you understand what I'm getting at? <leoprikler>Autocompilation is a wild beast and for the purpose of compiling and testing libraries it is best disabled. <ManDay>So what you're saying is that Autocompilation is effectively broken in parts <leoprikler>No, I honestly don't. Guile is in no way a build system on its own and treating it as such will yield subpar results. <ManDay>If it's no build system then why does it do the auto-compilation etc? <ManDay>It's like a half-arsed build system <ManDay>just you're telling me now, it's not good enough <ManDay>okay, nvm. So what build system DO you suggest I use? <ManDay>honestly, I've decided for scheme (and thus guile) for prototyping because I thought I would not have to put up with this stuff <leoprikler>Perhaps you're confusing it for (guix build guile-build-system), which invokes guild? <ManDay>i haven't needed a build system (i.e. a thing which figures out dependencies and re-makes things accordingly) because *I THOUGHT* guile does the job. <leoprikler>Pardon my French, but the snippet you've posted seems far from a prototype to me. <ManDay>and it does. but you're telling me it only works to a certain extent and I shouldn't rely on it <ManDay>leoprikler: i don't understand what you mean <ManDay>i'm just disappointed I have to concern myself with these things now. <leoprikler>Well, neither do I, but at least now we can admit that we're talking besides the point. <leoprikler>What are "these things" that you need to "concern yourself" with? <leoprikler>There is a good reason, why few people write web servers in a REPL. <leoprikler>For one, sooner or later processes tend to terminate. <ManDay>establishing a build system. which, according to what I have learned, I only have to do because I can't use guile for development properly, which in turn I have only seen by example because optimizations happen which potentially screw with debugging <ManDay>in repl? I'm not writing anything in repl? <ManDay>i'm not using guile interactively <ManDay>can I pass an -O through while using guile as my "build system"? <leoprikler>You can set the autocompilation options, but at that point I have to wonder why you're not invoking the compiler explicitly? <ManDay>leoprikler: you mean, manually (as opposed to writing a Makefile)? <ManDay>Because it's tedious to recompile all the files manually which I have changed. If guile wouldn't (allegedly) do it for me, I'd write a Makefile <leoprikler>Guile is pretty easy to set up with Automake and there's tools to help you. <ManDay>Which is kind of annoying, because I really haven't done this for a very long time. As a *real* build system I normally use CMake <RhodiumToad>using guild directly is likely to be very inconvenient since there's no simple way to turn all the warnings on <RhodiumToad>why in the nine hells would you use autotools when you don't need it <ManDay>leoprikler: autotools only over my dead body <leoprikler>Pretty much all serious Guile libraries use Autotools tho? <RhodiumToad>ManDay: I would say, ignore leoprikler and do it as you were. <ManDay>RhodiumToad: Thanks for the encouragement. What I will do though is follow leoprikler's suggestion about setting the default compile options <ManDay>(just looking for how to, currently) <leoprikler>I've searched for some libraries using Guile+CMake, but nothing useful shows up. <leoprikler>I have some personal experience with Guile+Meson, but Autotools feels better imo. <ManDay>''' For help on a specific command, try "guild help COMMAND" ''' <ManDay>leoprikler: I can't find how to set the default compile options, could you help me please? <RhodiumToad>%auto-compilation-options is probably the thing you're looking for <leoprikler>I'm not sure if those can meaningfully be set outside of a REPL. <ManDay>i think .guile only applies to the repl <leoprikler>You can of course do it via --eval, but that's kinda cheating and debugging support is worse than repl ;) <leoprikler>"debugging support" meaning if you type your sexp incorrectly <ManDay>so adding more cheats wont hurt ^^ <leoprikler>I think that'd make a little more sense if you wrote it as a guile script <leoprikler>ManDay: just for fun, try "guild compile **/*.scm" in your source directory and tell me what you end up with. <RhodiumToad>note that guild compile seems to default to no warnings enabled, which seems silly <leoprikler>I think the default is some warnings, but not the same as in auto-compilation <ManDay>leoprikler: I'm still trying to figure out at which point the error jumps from "line 6" to "line 1" and I am, indeed, trying to compile the scm directly now, but I'm having some trouble with load paths give me a while pleae <leoprikler>-L. for the current directory should suffice in most cases <ManDay>urgh nvm, I edited the wrong file (adding 'add-to-load-path') lol <leoprikler>uix environment --ad-hoc guile -- guild compile -W1 foo.scm <leoprikler>foo.scm:5:7: warning: possibly unbound variable `context.valid?' <leoprikler>guix environment --ad-hoc guile -- guild compile -W3 foo.scm <leoprikler>foo.scm:1:0: warning: possibly unused local top-level variable `tree-iterator-increment' <ManDay>ah, i found the problem. It stops working as soon as you put it into a library definition. i.e. try with this file: <RhodiumToad>leoprikler: whatever's handling that -W1 is not guild <ManDay>the error moves to "line 1" (now line 5) <leoprikler>guix environment --ad-hoc guile -- guild compile -O0 -W3 foo.scm <leoprikler>foo.scm:5:0: warning: possibly unbound variable `context.valid?' <RhodiumToad>ok, I do get unbound-vars warnings from guild 3.0.4 by default *RhodiumToad does not use guix <ManDay>Should I write this as a bug to the mailing list? <leoprikler>hmm, I'll try to figure something out real short <leoprikler>ManDay: It's at least related to the library syntax. <RhodiumToad>ManDay: does it behave the same if you use a guile module rather than the (library) wrapper? <leoprikler>If you don't wrap the define in (library ...), it vanishes as well. <leoprikler>If I add an additional (begin ...), it becomes <unknown-location> <ManDay>For a good Subject choice, what would you call that? Loss of line annotations? <leoprikler>Loss of location information in RnRS library forms <leoprikler>Though chances are it lands on top of the big pile of RnRS incompatibilities only to be documented ;) <ManDay>so you suggest I say it happens for modules? ;) <leoprikler>no, it doesn't happen if you use (define-module) <ManDay>What did you mean when you said: <ManDay><19:54 leoprikler> Also for guile modules, @RhodiumToad <leoprikler>What I meant was (library ...) (define x) – location info is there <leoprikler>(define-module ...) (define x) – location info is also there [this is what you'd usually write] <ManDay>oh you mean if you put it outside of the library <leoprikler>(library ... (define x)) – location info gets lost [this is what you'd write in RnRS] <leoprikler>Yes, but notice, that you can't put stuff outside the library form in RnRS <ManDay>yes, i learned that the hard way <leoprikler>For the record, Guile already documents its deviation from the RnRS standard in something closely related to that (multiple library forms) <RhodiumToad>presumably the loss of location info is an artifact of how the (library ...) macro is dealing with the body <leoprikler>fwiw, (begin (define )) on its own retains line info <leoprikler>Now if anyone can tell me what that is and what it's supposed to do… <ManDay>it's not an RnRS incompatibility as much as it is another screwed up debugging output/location <ManDay>compatible with rnrs it is, fortunally <ManDay>leoprikler: I think that looks pretty self-explanatory <ManDay>i'm joking, i have no idea what @@ @@ does <ManDay>urgh, I just noticed I mis-edited my email. Now it says something about an "rnrs module or guile library"... <RhodiumToad>(@@ module binding) accesses binding from module even if not exported, but I have no idea what the @@ @@ does <RhodiumToad>it's an undocumented thing to support the r6rs library macro... <leoprikler>but it gets expanded like so (@@ @@ (name name* ...) body) ... <RhodiumToad>but I'm betting that the stuff in (remodulate) messes things up <RhodiumToad>uh, expands into (begin (peek (cons 'a 'b)) (peek (cons 'c 'd))) and executes that? <leoprikler>now, what does (@@ @@ (name name* ...) body) ... expand to? <RhodiumToad>but it matches this form (_ @@ (mod ...) exp) and you will notice that syntax->datum is called on #'(private mod ...) <RhodiumToad>so if exp (the body form) is getting mangled, then it's in the (remodulate) call <ManDay>is "(remodulate)" something a normal person should know about? <ManDay>okay, that makes me feel better :) <RhodiumToad>it's a local definition buried in the guts of an obscure macro <RhodiumToad>(one which definitely deserves a "beware of the leopard" sign) <ManDay>thanks guys for the help with my issue. guess tomorrow I'll spend on converting my libraries to modules and hope this will work better <leoprikler>ManDay: it seems remodulate constructs a new syntax from the old one bound to a different module <leoprikler>the key here seems to be, that the source annotation seems to get lost, don't you think? <leoprikler>there is only a source-annotation on the outermost expression [the one that ManDay reports to be the one they get during debugging] <RhodiumToad>remodulate seems to be doing syntax-expression to get the content of a syntax object and then making a new syntax object around it <leoprikler>so the key would be to deal with the current-module-problem in r6rs libraries thereby eliminating the usage of @@ @@ <leoprikler>then at some later point we could completely remove @@ @@ <manumanumanu>ArneBab: I actually wrote a macro that youcan use to have defines in expression context in guile 2. I like to believe that andy saw the code, barfed, and implemented it properly <manumanumanu>Whereas guile3 turns everything in a body to letrec, that macro only turns successive defines into a letrec, so (define a 1) (define b 1) (display "what!") (define c 3) ... => (letrec ((a 1) (b 1)) (display "what!") (letrec ((c 3) ...) ***str1ngs_ is now known as str1ngs