<daviid>do we have an average builtin procedure? <polyphagia>how do i access a struct made with make-c-struct in scheme from the C api? <rlb>daviid: I suspect you're as likely to know as I am at the moment. While I think I'm reasonably good with Scheme and Clojure, I'm just coming back to more serious Guile use right now, while figuring this out. <rlb>Appreciate the help. ***holomorph is now known as Guest3385
***holomorp1 is now known as holomorph
<koz_>Does Guile have bindings for SQLite? <daviid>koz_: we do but the source code was on gitorious which is down. I have a local copy of the source that i can send you as a tar.gz if you wish to, it's small enough we can end it by email until uploaded somewhere else ... <koz_>daviid: I found them as a package on the AUR, so that's a non-issue. <koz_>It happens every time I re-run my script after changes, and it's annoying. <artyom-poptsov>koz_: Guile tries to compile programs and modules on the fly to speed up the execution. To silent this warning, pass '--no-auto-compile' to guile and remove related compiled .go file ('../arff2sqlite/arff2sqlite.scm.go' in your case.) <koz_>Is it sad that I already wanna write a macro called 'with-open-db'... :P <koz_>artyom-poptsov: I've added --no-auto-compile. Where does the .scm.go file end up? <artyom-poptsov>Of course, in a production environment you may want to compile modules and programs during the build phase and install .go files along with .scm files, so users won't need to compile everything by themselves. <koz_>artyom-poptsov: This is a one-off script only for me. <koz_>Is there a case-insensitive string-prefix? predicate? <koz_>Never mind, apparently I'm just blind. <koz_>What's the Guiley (or rather, Schemey) thing to do when you want an enumerated type? Would I just use symbols? <nalaginrut>koz_: for an alternative, you may take a look at guile-dbd-sqlite3 <koz_>Alrighty, symbols it is. <koz_>I've worked with Common Lisp before, and I've read R5RS and R7RS, but Guile is... big. <nalaginrut>personally, as a practical one, I believe it has to be big, although there're many modules could be separated if guildhall become popular <koz_>Also, could someone help me make sense of scm-lalr? <koz_>Its documentation isn't exactly what I'd call 'thorough'. <koz_>I mean, if there's a better-documented parser generator for Guile, I'll take it. <koz_>I just really have no clue what's going on. I've never used Flex and Bison and co. <wleslie>in the top description, it says, an expression (e) is defined as the sequence (expression, + symbol, term) or (expression, - symbol, term) or (term) <koz_>I need to write a script to convert ARFF files to SQLite databases. <koz_>I'm pretty sure a hand-rolled parser is the wrong approach. <koz_>e (e + t) : (+ $1 $3) <-- I assume this means 'if you match this, sum whatever 'e' was and whatever 't' was, right? <wleslie>I would probably not use a lalr parser for this, but that's me <koz_>wleslie: What would you use? <wleslie>I'd iterate over the lines and split on commas <koz_>wleslie: That's just the data part. <koz_>The header also needs parsing. <koz_>So you reckon a hand-rolled parser would be easier? <koz_>(it also has to handle comment lines and also end-of-line comments as well) <wleslie>in situations like this where there's no recursion involved, I usually write a parser by hand <koz_>Alrighty. I can hand-roll a parser, I guess <koz_>So should I just read in the whole string and hack at it until it's in a format I want? <koz_>Alrighty - I guess if memory becomes a problem I can do something different. <koz_>ACTION goes to read more Guile manual. <koz_>nalaginrut: Thanks for that. <nalaginrut>ACTION is considering to revive guile-lua-rebirth <koz_>How would I write a string in Guile that consists of only the newline character? "\\n"? <fps>hmm, i'm pretty new to guile (and scheme in general) and i wonder how to solve this problem: let's say i have a program like this: <fps>for every package i add to the packages list i need to import some module (sometimes, more than one package is defined in the same module) <fps>i'd like to avoid having to write the use-modules calls manually <fps>there's a function find-packages-by-name <fps>which returns a package "thing" (a structure?) <fps>so i wondered if i need to learn about macros to solve this.. <fps>sooo, to tackle this i have to solve two problems i suppose: <fps>1] scheme@(guile-user)> (find-packages-by-name "emacs") <fps>$4 = (#<package emacs-24.5 gnu/packages/emacs.scm:63 3522780>) <fps>i need to find out what th result of this is precisely <fps>and how to get the module out of it short of parsing the path :) <nalaginrut>fps: maybe you need resolve-module, but I suggest you read this part first <fps>nalaginrut: ok, will start with that <fps>resolve-module might be useful once i have '(gnu packages emacs) assembled, yes :) <fps>hmm, there are procedures exported for package structs, like package-full-name, but they don't like the value that find-packages-by-name returns.. maybe i need a car :) <fps>scheme@(guile-user) [4]> (package-full-name (car (find-packages-by-name "emacs"))) <fps>ah, ok, will fiddle a bit <fps>nalaginrut: actually yeah, while under the shower it occured to me that it's much simpler probably.. :) <fps>just slapping it onto there with: (packages (append (find-packages-by-name "wget") (cons* xmonad dmenu %base-packages))) works just fine :) <fps>so i need to do nothing actually <fps>thanks for the help, you kind people :) <wingo>i wonder why that is, perhaps #e1e9 is a bignum on 32-bit machines <wingo>solrize: what's the value of most-positive-fixnum on your machine <solrize>scheme@(guile-user)> most-positive-fixnum <wingo>so if you loop to #e5e8 you should get better numbers <wingo>that said, that particular case is one in which we could unbox integers, perhaps we should start doing that... <solrize>32.75 seconds, in line with your x86 timing i guess <wingo>2 tag bits for fixnums, then they are signed <solrize>python3 at 3m20s and still going strong :) <wingo>i use luajit at work and it is a delight <solrize>can any of its methods be adapted to guile? <wingo>not really, unless we decided to switch course and do a tracing jit based on bytecode, and write a bunch of gnarly c <wingo>but c kills my soul, so i want to stay self-hosted, meaning getting to luajit's perf is a longer road <solrize>well, i meant reimplementing some of luajit's algorithms in scheme <solrize>yeah i was looking at that, i posted the comment mentioning luajit, not realizing you had posted about it earlier <wingo>luajit gets good perf not so much from an algorithm perspective but from tracing <wingo>i mean, we already implement most of what luajit does besides the last bits for native compilation <solrize>hmm ic. i remember it had a linear scan register allocator which is supposedly almost as good as a traditional one but much faster <wingo>so the next checkpoint is to see where we are once we start doing aot native compilation <solrize>yeah that will be cool... ocamlopt might also be worth looking at <wingo>linear scan is fine, though a bit fiddly to know when to split live ranges <wingo>iirc tinycc doesn't do register allocation <wleslie>there's a great lgpl compiler backend called libfirm that is very cool <solrize>wleslie, oh neat i never heard of that <solrize>wtf, a domain squatter seems to have gotten cminusminus.org <solrize>wleslie, that page says firm is even slower than llvm :( <solrize>wleslie, yeah but i think it's intended to be a heavyweight compiler backend like llvm <solrize>andy there's another maybe-issue: guile 2.1.1 won't build on debian 7 (wheezy) because wheezy has a too-old version of libgc (8.1)... does guile actually care about whatever might have changed in 8.2? <wleslie>should just modify the guile 2.0.11 guix expression and build with that <wingo>solrize: you can build bdw-gc from a tarball. yes guile 2.2 needs libgc 7.2 <solrize>ok. yeah i figured i could download bdw, just thought there might be a packaging problem regarding wheezy and guile. i guess i'll do the download at some point, but it's getting to be bedtime here at the moment <solrize>if you want one of these arm servers i can have them send you an invite code.... they're currently not taking public signups but they're not completely out of hardware <wleslie>I'm still putting off the upgrade to jessie too P: <lloda>you can't use set! like that <koz_>lloda: Is it globals-only? <lloda>it's how variables work in Scheme, they're names, not places <lloda>say ((lambda (y) (set! y 9)) x) <lloda>that changes the value assigned to y, but does nothing to x <koz_>So how should I do the thing I want to do? <amz3>use set! outside the lambda <koz_>amz3: That... really doesn't help solve my problem. :P <amz3>in admit! do: (make-trie entries) instead of (begin (set! trie ...)) <lloda>I think the common Schemish advice would be to build a new structure instead of modifying what you have <lloda>you can also try set-car! and set-cdr! <koz_>I guess I could do it that way. <koz_>Alrighty, back to thinking. <ArneBab>wingo: the global story sounds reasonable. Did you think of that ahead of time when switching to the ELF format? <darthlukan>I've recently been turned onto Guile via a search for Scheme implementations after taking a class that used Racket as the teaching language. I've installed Guile and have used it to write a small program that converts temperatures between Celcius and Fahrenheit and was wondering if someone would be willing to provide some tips on how to improve it <darthlukan>Basically, if I made any faux pax or did something in a more complex way than Guile provides <amz3>darthlukan: why use have an empty string in L19 and L20 as in (string-append "" (number->string ...)) <amz3>in guile you can declare a procedure as (define (my-proc a b c) ...) <darthlukan>amz3: I was getting errors using string-append stating a type error because of the number <darthlukan>amz3: So I added the string in front and then it worked <mark_weaver>darthlukan: I think it was the use of 'number->string' that fixed that problem. <darthlukan>mark_weaver: that's what I had initially, but I kept getting the error until I used the empty string <darthlukan>is there maybe a better way to generate a formatted string without needing string-append? <darthlukan>awesome! Do you know which doc I should read for that off-hand? <mark_weaver>in emacs, looking at the guile manual from the 'info' reader, you can just type 'i' and then type "format" and return. <mark_weaver>also, see the procedures 'string-take-right' and 'string-drop-right', which are a nicer way to split the temp from the unit. <mark_weaver>instead of (/ (* t 9) 5) you can do the equivalent (* 9/5 t) <mark_weaver>9/5 is a syntax for a numeric literal, there's no division happening when the program runs it. <mark_weaver>guile has support for arithmetic of exact rational numbers, and that's the syntax used for them. <darthlukan>okay, I must have misunderstood that when reading the docs <mark_weaver>did you want to round the results to integers, or was the problem that the results were being displayed as exact rationals and you wanted to avoid that? <darthlukan>The results were being displayed like: "327/123C" <darthlukan>and I wanted to actually display either whole numbers or floating point numbers <darthlukan>the quickest way to get to an acceptable output was round from what I saw (I noticed there wasn't a "float" type) <darthlukan>or maybe there is and I missed it (or it's called decimal)? <mark_weaver>the easiest way is to use ~g instead of ~a in the 'format' call. <mark_weaver>scheme treats numbers differently than most other languages. there is no concept of floating point numbers vs integers. <mark_weaver>there is a concept of "exact" numbers vs "inexact" numbers <mark_weaver>in scheme, (/ 1 2) is 1/2, whereas most languages would give 0, which seems rather dumb to me :) <darthlukan>right, because you are expecting some representation of 1/2, either as 1/2 or 0.5 <darthlukan>so I guess I just need to specify with the appropriate format character which representation I wish to display <mark_weaver>in scheme, literals with a decimal point or exponent, e.g. 0.5 or 1e2 are inexact numeric literals. <mark_weaver>so 1/2 and 0.5 are numerically equal, but one is exact and the other is inexact. <mark_weaver>as scheme does numeric computation, it keeps track of whether the number is exact automatically, based on whether the inputs were exact and whether the operation could be done exactly. <mark_weaver>if you want to force inexact computation and printing, another common way is to use 'exact->inexact', or to deliberately introduce an inexact number into the computation, e.g. by changing the 32 to 32.0 <mark_weaver>but in this case, the cleanest solution is probably to use the ~g format specifier. or ~f if you prefer. <darthlukan>yeah, ~f looks like what I want (based on the output I'm seeing) <darthlukan>oh, cool! Digits after a decimal point are similar to other languages: "1.2f" in Python versus "~1,2f" in Scheme/Guile <darthlukan>the use of lambda in procedures: convention or some subtle purpose that the books I've been following haven't expanded upon? <darthlukan>in one book it mentioned it as a convention, but didn't explain why <Petit_Dejeuner>darthlukan: You mean (define add (lambda (a b) (+ a b))) instead of (define (add a b) (+ a b))? <mark_weaver>'lambda' is the fundamental way to create procedures. other ways of creating procedures are only syntactic sugar for the same thing. <darthlukan>In guile is it considered a better practice to use one over the other? <darthlukan>or is it pretty much whether or not you prefer more compact notation or not? <mark_weaver>some people prefer to always use 'lambda', and I can sympathize with that. among other things, it means that when you use 'lambda' in a call to 'map' or some other higher-order procedure, or use 'lambda' with a 'let', it looks less strange because you're used to it. <mark_weaver>in practice, most people tend to avoid using 'lambda' and use the (define (proc args ...) ...) sugar instead, but sometimes I think that was a bad idea. <ArneBab>darthlukan: I’ve seen the lambda form a lot in Racket, but on the other hand when you use (define (foo bar) …) (foo 1), the definition looks like the call <mark_weaver>well, most of the code I write is for other projects where there is already an established set of conventions, and usually those conventions use the 'define' sugar. but sometimes on my own projects I use 'lambda' consistently, or even 'λ', which is recognized by guile by default. <ArneBab>I tend to use the sugar, but I’m still pretty new to scheme myself. <darthlukan>I'm new to scheme as well ArneBab, got turned onto it during a class that used Racket/Scheme as the language <darthlukan>So here I am, trying to learn enough to at least be useful <darthlukan>and maybe to be able to contribute to Guile if I get good enough at it <darthlukan>I'm on the user and dev mailing lists, so I can have examples through patches to read and try out. Same thing I did when I learned Go <OrangeShark>darthlukan: it used to be less than 100 users a couple of days ago <darthlukan>new website looks fancier than a few days ago :) <darthlukan>well, that's good that there are more people, more GNU users :) <dsmith-work>darthlukan: Used to be around 60 or so a few months ago. <darthlukan>davexunit: just takes a decent questions/topic of conversation and one or two good responses to get things rolling :) <darthlukan>ArneBab: That's what it's there for :) Oh! You did some fancy stuff in there with print-converted-temp <darthlukan>Yeah, but you used a "let" and some formatting trickery too, that's what I'm reading to make sure I understand it correctly <ArneBab>darthlukan: mind the (use-modules (ice-9 format)) <darthlukan>when I tried to use the ~g that mark_weaver mentioned, I got an error, then I saw in the error that ice-9 format was recommended/where that could be used, so I figured I'd import it <darthlukan>Guile Basic Strucutres == Standard Library (as in, "The Python Standard Library")? <ArneBab>Guile has ice-9, but it also has many SRFIs — both together form a kind of standard libray <ArneBab>ice-9 ~ Guile Standard Library, SRFI ~ Scheme Standard Library <ArneBab>example for SRFI: (use-modules (srfi srfi-1)) <darthlukan>so if I'm trying to write something that any Scheme implementation can consume, I would avoid ice-9 and try to use the srfi instead? <darthlukan>I typically work in integration, so portability challenges are always in the back of my mind ***thorwil_ is now known as thorwil
<ArneBab>I did not write for multiple scheme versions yet, but others here do. <darthlukan>well, one thing that's great about where I work, I'm allowed to use the best tool for the job (within limits), so it would be nice to be able to write something up in Guile/Scheme and then be able to use it at work where I have to use that other OS <ArneBab>AFAIK you can use Guile on the other OS, but I did not try that yet <darthlukan>neither have I, hopefully, I won't have to soon :) <darthlukan>Because of my productivity and the docs I've written for coworkers, my employer is looking at migrating everything to a Linux based stack <darthlukan>So hopefully soon I'll have something in Guile/Scheme for production use :) <darthlukan>just have to get over the initial learning curve <darthlukan>Excellent, I come from a Python-heavy background as well <darthlukan>Now I know who's brain to pick when I come across something grossly unintuitive to a pythonista :) <ArneBab>feel free to ask — though I might at times take some time to answer <darthlukan>I noticed the Wisp thing you linked had German links <solrize>yeah i just saw that linked from ArneBab's page ***healer``` is now known as healer
<davexunit>finger trees with a better cache story for today's processor ***healer` is now known as healer
<paroneayea>davexunit: I wish I understood more of those datastructures <ArneBab>solrize: I did not try Erlang, Haskell or ML, no. I decided to go for Scheme, because compared to Python it is a diametrally different philosophy while working on the same level of abstraction (though I found that Scheme is at the same time more low level and more high level than Python) <ArneBab>paroneayea: I plan to get me an algorithm book after finishing my PhD — as a reward for pushing through the last months of work. <solrize>ArneBab, you might try some of them just to see what they are like <ArneBab>solrize: I decided to learn one language, because want to learn a language right before moving on. <paroneayea>ArneBab: I have an algorithms book, but it's not the best one <ArneBab>solrize: estimating surface fluxes of CO₂ from athmospheric measurements. <paroneayea>it's engaging, but they go everything really fast <solrize>have you looked at SICP? it's pretty important for scheme users imho <ArneBab>throwing lots of Statistics and Python and Fortran and meteorological data at measurements to find a better estimate of the uncertainty of continental fluxes :) <solrize>but, i think of scheme as something like an assembly language, very flexible and powerful but too low level to want to use directly <paroneayea>it's great, and does a lot about the nature of computation <solrize>www.amazon.de/Introduction-Algorithms-Thomas-H-Cormen/dp/0262533057 this is probably the main book here <ArneBab>I also plan reading Numerical Recipes in C <solrize>i think the serious numerics people hate it because it simplifies things more than they want, but it's more understandable that way :) <ArneBab>I plan to ☺ but first I have to finish my PhD thesis… <solrize>i don't know of a good book about statistics and machine learning... i've been interested in that <solrize>i haven't looked at that yet, but that's a software package right? i want to understand the math better <solrize>i've used R a little bit but don't remember anything about it any more <ArneBab>They have some tutorials, but I don’t know how deep that goes into the math. <solrize>ArneBab, if you're into this language stuff enough to write that scheme book, i really recommend trying haskell next. it's the most interesting thing i've ever done as a programmer <solrize>learnyouahaskell.com is a good place to get started <solrize>oops that's a shopping page comparing the book to harry potter, but it's from the book site <ArneBab>there is a lot to learn about scheme to really understand it <solrize>is it stuff that's worth the trouble of figuring out? <solrize>most of the scheme i know is from sicp which doesn't go that deeply into the language details <dsmith-work>solrize: Ya, I've been going through that one lately <solrize>dsmith-work, sicp? yeah that's a book everyone should read <solrize>oh, yeah, that's a good book though i think learnyouahaskell is more accessible for haskell beginners <solrize>i have the old edition of sicp on paper <solrize>not sure how different the new one is <ArneBab>I don’t think that I can really understand the language without giving it solid real world usage (though that might be in hobby projects) <ArneBab>let it inspire my style of programming <solrize>miranda (described in the article) is a predecessor of haskell <solrize>scheme as i've seen it isn't that much different from python <davexunit>I think you need to take a closer look at Scheme, then. :) <dsmith-work>Scheme can be used in many ways. I'm sure you can program in Python (stylistically) with Scheme. ;^) <solrize>yeah i saw something saying scheme has one-shot continuations now, like python generators <davexunit>scheme has had continuations for longer than python has existed. <dsmith-work>Basically, a continuation that can only be used once. <solrize>one-shot continuations means they don't stay around after you switch to them, so there's no time travel like in call/cc and you don't have to GC the call frames <solrize>oleg kiselyov has an article about call/cc being broken <davexunit>Guile has delimited continuations, if that's what you mean. <solrize>yeah, oleg says delimited continuations are better than call/cc <davexunit>delimited continuations allow one to implement generators and other such things <davexunit>I have a coroutine implementation built on them. <solrize>do you use coroutines much? i've wanted them a few times <davexunit>my game engine is driven by them, under the hood. <solrize>there's a good paper about them by one of the lua implementers <davexunit>to allow for asynchronous code that can be written linearly. <davexunit>cooperative multitasking has significant advantages for certain use-cases. <davexunit>with games, I don't want parallel execution, but I do want async behavior. <davexunit>(I do want threads for very particular tasks such as loading files in the background, but not for game logic) <davexunit>and I have that "holy crap this actually works!" moment again <solrize>davexunit, what do you gain by using coroutines? i guess they're a bit lighter weight but if the idea of async is that the tasks are usually paused for i/o then it shouldn't matter much <davexunit>I gain a lot: multi-tasking without the complication of thread synchronization. <koz_>Can I use eq for comparing something to #f or should I use eqv? <solrize>i've generally had the threads communicate with message passing and that avoids the usual lock hazards and so on <solrize>anyone here use clojure much? i think it has some things that don't naturally map onto scheme <ArneBab>solrize: the coroutine usage by davexunit was a mind-opener for me: suddenly things where possible which were unthinkable with python. <ArneBab>because Scheme can actually create the code needed to do them <koz_>solrize: What do you mean exactly? <koz_>I know some Clojure (used to be a fan until I found I can't GPL work under it). <ArneBab>solrize: people here have been implementing some Clojure ideas for Guile <solrize>(can't gpl stuff???!!! wonder how they stop that). but i think clojure has some concurrency stuff that would be hard to do in pure scheme <davexunit>clojure has different types of applicable things, which scheme doesn't have. <solrize>i've looked at clojure a little bit but not used it because the jvm icks me out :). i've wanted a standalone version <davexunit>I don't see much reason to use it if not on the JVM <koz_>solrize: Clojure is EPL-licensed, and any code written in it has to be linked against Clojure itself. <koz_>Static linking with EPL = GPL-incompatible. <davexunit>and clojure does copyright assignment! to rich hickey! <koz_>Yup, and they seem to be interested in precisely zero discussion on this topic. <koz_>Well, CLAs are another story. <solrize>yuch. don't know what epl is but yeah, that sounds like a turn-off <koz_>solrize: It's the same license the Eclipse people use for their utter piece of shit software. <koz_>Designed to make *another* piece of shit software not so bad. <daviid>I noe use kawa instead, which actually is about 100 better then clojure anyway <davexunit>that's 2 big legal issues with clojure for me. won't use it unless paid by employer. <koz_>davexunit: I just won't use it full stop, since my employer doesn't care what language I work in. :P <daviid>koz_: oh that's cool and rare, need yelp? :) <ArneBab>not elegantly — “All Turing-complete languages differ solely in syntactic sugar.” — Michele Simionato in The Adventures of a Pythonista in Schemeland34 <koz_>daviid: I'm a PhD student. <koz_>People care more for my ideas than the language I implement them in. <ArneBab>being able to adjust the syntax makes a big difference for an API, since the basic API of any system never fits your problem perfectly <davexunit>the macro stuff certainly cannot be done in python <koz_>OK, I'm getting *real* frustrated now. <solrize>davexunit, yeah, python syntax is constraining sometimes <koz_>All I wanna do is implement a trie that can add new branches. <koz_>(i.e. I don't know my alphabet ahead of time). <koz_>I tried to do this using assoc-lists, but then I had the problem of nested modification. <koz_>I thought about records, but they need a fixed number of fields, which I can't provide. <koz_>This is meant to be a simple prototype, and I can't even seem to get it off the ground. <davexunit>you could make a node type that has a list of branches? <koz_>davexunit: It'd have to be an assoc-list, but I guess that works. <solrize>well if the alphabet is big that slows it down <davexunit>alists are faster than hash tables up to a certain scale. <davexunit>you should be able to swap the structure if needed. <davexunit>best to focus on making the thing work at all. <solrize>why are you trying to implement a primitive structure like this anyway? <koz_>solrize: I'm working on a new supervised learning technique that can be distributed well. <koz_>This is a test of one of my ideas. <koz_>I'd like to use Guile more, so I figured I'd try it in Guile. <solrize>implementing a trie? there's no library for it? <koz_>davexunit: I agree - I'm not used to doing it in Guile. <koz_>The language I used for my Master's data structure was Lua. <koz_>(the print thing is for inspection purposes, mainly) <davexunit>koz_: you've quoted something that you want to be evaluated <davexunit>quasiquote is nicer since it's a hardcoded value <koz_>Thanks! That was a serious derp on my part. <koz_>Also, does newline take a port argument like display? <koz_>That's somethign I'll have to remember.