IRC channel logs

2015-10-22.log

back to list of logs

<davexunit>ACTION tries to see if there's some way to encode additional information in a texinfo file that will allow me to perform syntax highlighting on the text in an @example block.
<ArneBab>davexunit: maybe javascript-based highlighting?
<davexunit>ArneBab: same problem.
<davexunit>I'm definitely going to avoid javascript highlighting, though.
<ArneBab>ok :)
<cmhobbs>can anyone point me to documentation for how i might open a tcp port with guile and send/receive strings from it?
<wleslie>if you want to send and receive strings over TCP, the first thing you'll need to do is decide upon a message framing format
<wleslie>because TCP is not a message protocol, it's a stream protocol
<cmhobbs>i'm trying to communicate with gnu go in gtp mode
<cmhobbs>i've done this with ruby with the TCPSocket class and the puts method
<cmhobbs>do i need to handle lower level stuff by hand in guile?
<wleslie>cool, so you've already got a format for the messages
<cmhobbs>7.2.11.4 Network Sockets and Communication looks promising from the manual
<cmhobbs>right, yeah
<cmhobbs>gtp just takes strings though
<wleslie>if you intend on handling sockets yourself, there's a bunch of functions in the main namespace for working with sockets: https://www.gnu.org/software/guile/manual/html_node/Network-Sockets-and-Communication.html
<wleslie>you'll need to convert between bytevectors and strings, too
<cmhobbs>i'm not sure i need to. i'd just like to connect to a port
<cmhobbs>ok
<wleslie>yeah, you can just use the port interface
<cmhobbs>i'll dredge that up in the guile manual
<cmhobbs>im digging through the socket stuff right now
<mark_weaver>you can write and read text strings directly to/from the socket port, so there's probably no need to use bytevectors.
<cmhobbs>mark_weaver, where should i dig in the documentation for that sort of thing? got any useful function names i can poke at?
<cmhobbs>i'm still getting started with guile so i don't have the docs
<cmhobbs>in muslce memory yet
<cmhobbs>muscle*
<cmhobbs>i'm looking into ports and file descriptors now
<mark_weaver>the link that wleslie gave above covers the socket side of things
<mark_weaver>after that, it's the same as I/O to any other port type.
<cmhobbs>ok, cool
<mark_weaver> https://www.gnu.org/software/guile/manual/html_node/Input-and-Output.html
<cmhobbs>thanks, folks!
<cmhobbs>that should get me started
<mark_weaver>okay, feel free to ask questions here as needed
<cmhobbs>thanks! i've been struggling to find time to get guile under my belt, so it's coming in fits and starts :D
<cmhobbs>i'll have some downtime tomorrow, so i'm trying to prep some docs
<roelj>Is there anything special I need to do to get (procedure-source) to work?
<amz3>funny it doesn't seem to work
<amz3>ACTION digging the source
<amz3>it expects a program
<amz3>procedure-sources is really program-source
<amz3>is defined guile/module/system/xref.scm
<roelj>amz3: Ehm, can I in some way treat a procedure definition as a list?
<roelj>(I would like to treat it as a syntax tree actually)
<amz3>roelj: in a macro yes
<amz3>roelj: see define-syntax & syntax-case
<taylan>roelj: what exactly is it that you're trying to do? (from a higher-level perspective)
<roelj>taylan: I have a function with decision-making criteria (which boils down to a bunch or predicates). When the program is running, I would like the program to be able to alter the predicates (which I'm limiting to adding and/or removing predicates).
<taylan>roelj: maybe you could keep the predicates in a data structure, like a list, vector, or table?
<amz3>^
<roelj>taylan: Yes, that would be awesome. But how can I store unbound variables in them? So when I have: (< a +inf.0), then how can I represent the a (which will be bound later) in the list?
<roelj>Should I use a macro for that, like amz3 said?
<amz3>taylan knows better. I think you should use procedure to bind the unbound variables at runtime ((lambda (a) (< a +inf.0)) 42)
<taylan>roelj: hmm, I don't understand how that relates to keeping the predicates (not variables) in a data structure. can you elaborate? normally, you can just put e.g. (lambda (a) (< a +inf.0)) into the list, and later just call it on some value. (probably every predicate in the list should take the same number of arguments...)
<taylan>very small example system: (import (srfi :1)) (define predicates '()) (define (passes-all? x) (every (lambda (pred) (pred x)) predicates)) later: (push! predicates (lambda (x) (< x +inf.0))) (push! predicates (lambda (x) ...)) (passes-all? 5) => whatever
<taylan>(push! isn't defined in the standard environment. a proper data structure might be better anyway though.)
<amz3>roelj: are you building a decision tree?
<amz3>ACTION wonders how he wrote so much code
<roelj>amz3: Yes I suppose I'm writing a decision tree. And I want to add new conditions to the decision tree while running the program.
<roelj>Let me try to write a small example code
<amz3>cool
<davexunit>alright, I implemented a way to highlight code blocks in texinfo documents for my blog.
<davexunit>using a little emacs-style hack
<amz3>you use texinfo for the source of your blog?
<davexunit>i'm going to.
<amz3>hmm
<davexunit>I was experimenting to see how well it worked.
<amz3>what's the advantage of texinfo over skribe?
<davexunit>the advantage is that it is nicer to write in most cases
<davexunit>emacs already has a really nice mode for working with it
<davexunit>the disadvantage is that I have no way to insert code when the need arises.
<amz3>I think pollen parser is easier to write that markdown because it has an escape sequence
<davexunit>the issue I have with Pollen is that you write plain HTML or whatever else
<davexunit>I don't like that aspect at all.
<davexunit>Skribe is better in this sense, but in practice I'm finding Skribe hard to work with.
<amz3>maybe I'll end up fixing combinators to work like I want, and add pollen syntax to it
<davexunit>perhaps mostly due to missing the necessary elisp to make it pleasant.
<amz3>hmm
<amz3>I don't have that requirements
<amz3>and did not write much skribe either, i did not seem bad
<rekado>writing a blog in texinfo format is a neat idea.
<davexunit>rekado: it totally works! guile already has built-in texinfo stuff which works great.
<davexunit>I just needed some extra pre-post-order SXML transformation to find 'pre' tags and highlight the code within them.
<davexunit>the big downside being that you can't insert scheme code within them.
<davexunit>and the markup being rather unextensible.
<rekado>guile-emacs segfaults for me when I load my full configuration file.
<taylan>my .emacs also has problems. I should learn how to use GNU C debugging tools properly and get to looking into things...
<davexunit>you can play the ol' configuration bisect game to find the offensive code
<rekado>I've been playing this already and it seems that it's nothing in particular that causes this. Just *anything* after the point where I'm loading up magit seems to crash it.
<rekado>I had to remove a couple of things from the config already, but those were scheme exceptions, no segfaults.
<rekado>or maybe the segfault has nothing to do with my config but with the attempt to restore a desktop.
<rekado>yup, there is no segfault when I comment the expression (desktop-save-mode t)
<daviid>hello guilers
<sneek>Welcome back daviid, you have 1 message.
<sneek>daviid, ArneBab_ says: arne_bab -ät- web -dot- de
<daviid>sneek botsnack
<sneek>:)
***dje is now known as xdje
<amz3>daviid: how clutter is going? do you need help to test?
<daviid>amz3: be with you in a min
<daviid>amz3: clutter is fne, but if you want to help, you could can guile-lib and try to help me solve the make check 1 test failure, that would be awesome
<daviid>s/could grab guile-lib
<amz3>sure
<daviid>cool! let me know
<daviid>amz3: http://git.savannah.gnu.org/cgit/guile-lib.git/
<amz3>yep I'm building
<daviid>great
<amz3>daviid: the error is in api.scm ?
<daviid>just a sec
<daviid>oh, it pass! i'm working on a devel branch and made modification to the autool config. the failure was in texinfo.serialize.scm
<daviid>
<daviid>does it pass for you?
<amz3>rebuilding
<daviid>davexunit: for info, ssax ssax-simple are guile-lib sxml modules
<amz3>same error: https://friendpaste.com/5s3dItRpcpq3dH1E4LKctl
<daviid>amz3: I can not reproduce that here, and the devel branch [which I did not push my modifs yet] pass amke check now
<amz3>ok cool
<daviid>you copied part of the trace, did it make fine fails make check or fails make ?
<amz3>make is ok
<amz3>make check fails with the backtrace I pasted
<daviid>ok, then let's wait i finalize the modifs on the devel branch, then you try again [not today though]
<amz3>ok
<amz3>good luck
<daviid>tx
<karhunguixi>i'm working my way through a tutorial and am puzzled at why i can do: "(map 1+ (iota 5))", but not "(map 2+ (iota 5))"
<amz3>1+ is a procedure
<amz3>(equals? (1+ 2) 3)
<karhunguixi>procedure is like a function, right?
<mark_weaver>karhunguixi: '1+' is just a name like 'map' or 'iota'.
<karhunguixi>hm, weird name
<mark_weaver>and it so happens that '1+' is bound to a convenience procedure that adds one to its argument, but no such binding for '2+' is provided.
<karhunguixi>thanks, that clears it up
<mark_weaver>np!
<karhunguixi>amz3, that (equals?.. code fails for me, what is it supposed to illuminate?
<amz3>sorry there is no s
<amz3>(equal? (1+ 2))
<karhunguixi>ok, #t
<amz3>sorry again :)
<amz3>(equal? (1+ 2) 3)
<amz3>it means that 1 + 2 == 3
<amz3>equal? is the procedure to test equality by value
<karhunguixi>same as: (equal? (+ 1 2) 3)
<amz3>in this case, eq? can replace equal?
<amz3>yrd
<amz3>yes
<amz3>ACTION afk
<taylan>eq? shouldn't be used for numbers. (eqv? is fine.)
<karhunguixi>what does the 'v' stand for?
<taylan>eq? is an efficiency hack over eqv?. for anyone interested in the precise equivalence semantics of Scheme, it's best to try to understand eqv? first.
<taylan>eqv is short for equivalent
<karhunguixi>ah, ok
<taylan>the terminological distinction between "equivalent" and "equal" is not that clear I think. I'm guessing it's due to some historic reasons, but not sure.
<taylan>eqv? tries to approximate the concept of "operational equivalence" though, maybe it's from there
<karhunguixi>ok, it's of secondary importance to me. I like to know what things spell out, even if it's not correct (anymore)
<taylan>yeah, it helps as a mnemonic...
<karhunguixi>thanks for your input
<taylan>happy to help :)
<mark_weaver>karhunguixi: for numeric comparisons, it's usually more appropriate to use '='
<mark_weaver>(= 0 0.0) is true, but (eqv? 0 0.0) is false
<mark_weaver>and (= 0.0 -0.0) is true, but (eqv? 0.0 -0.0) is false
<mark_weaver>and equal? is the same as eqv? for numbers.
<mark_weaver>eqv? tests for "operational equivalence", whereas '=' tests for numerical equality. they are subtly different concepts.
<mark_weaver>you need operational equivalence to implement memoization, but in most other cases '=' is what you want.
<karhunguixi>Aha, this is good to know! Thanks, Mark!
<mark_weaver>you're welcome!
<ArneBab_>karhunguixi: (1+ 2) is equivalent to (+ 1 2). You can define it yourself with (define (1+ x) (+ 1 x))
<paroneayea>I like that The Art of the Propagator has a small footnote at one point, simply saying
<paroneayea>Equality is a tough subject
<paroneayea>too true D:
<karhunguixi>ArneBab_, what would you call this? maybe procedure overwriting?
<rekado>karhunguixi: "procedure definition". With 'define' you are binding a procedure to a name in the top-level environment.
<karhunguixi>what about when there's already one with the name you specify
<karhunguixi>is it possible to "redefine" all procedures?
<rekado>you can redefine procedures.
<rekado>you can try this in an interactive session.
<rekado>I just did this:
<rekado>(define (1+ x) (+ 10 x))
<rekado>(1+ 7)
<rekado>$1 = 17
<rekado>it's probably not a good idea to do this at the top-level, though.
<karhunguixi>yeah, i've tried this. Was just wondering in general if there were any special procedures that's not possible to redefine
<karhunguixi>just out of curiosity
<rekado>you can even shadow things like "if".
<rekado>I don't know if anything is really sacred :)
<rekado>this fails: (define (define x) x)
<rekado>but only because "define" in the subexpression is expanded first (and then triggers a syntax error).
<karhunguixi>shadow means redefining only for the current scope?
<rekado>but "define" is not a procedure, it's a special form
<rekado>"shadowing" is "covering" a previous definition with a new definition.
<rekado>it is used when a name is bound in an outer scope as well as the current scope.
<rekado>the binding at the current scope is said to "shadow" the other binding(s) (in this scope).
<rekado>(let ((a 10)) (let ((a 20)) (display a)))
<rekado>the inner binding of "a" shadows the outer binding; "20" is printed rather than 10.
<rekado>ACTION goes afk
<karhunguixi>right, thanks!