IRC channel logs

2017-11-03.log

back to list of logs

***akkad is now known as Ober
<xelxebar>Dumb question: Is it idiomatic to define procedures in local bindings? (let foo (lambda...) ...)
<terpri>xelxebar, it is
<xelxebar>terpri: Thanks :)
<xelxebar>Wait. What differences are there between an internal define vs let-binding a lambda?
<amz3>xelxebar: internal define is not idiomatic
<amz3>xelxebar: this goes full circle but that's the only difference I see between the two
<xelxebar>amz3: Thanks :)
<amz3>xelxebar: there is something specific about the compilation of internal define
<amz3>xelxebar: but I don't remember the name of the algorithm
<amz3>xelxebar: also, after 4 years of doing scheme, I used only once let lambda, actually it was a letrec, I usually define helper function at the top level because this way they are testable
<amz3>that instance of letrec lambda is very specific, because I want to take advantage of lexical scoping (the closure actually) but it leads to untestable code
<amz3>xelxebar: if you are worired to define lambda inside a map procedure like (map (lambda (item) (proc lexical-var-1 lexical-var-2 item))) lst)
<amz3>you can use srfi-26's 'cut' form
<amz3>or you can use curried definition (see the manual)
<amz3>or my prefered method, is to do things like (define (helper lexical-var-1 lexical-var-2) (lambda (item) ...) and then use it (map (helper lexical-var-1 lexical-var-2) lst)
<amz3>that way there is no big untestable mess inside your function
<amz3>s/function/procedure
<nalaginrut>xelxebar: don't worry about inner define, they're equivalent to let binding in a body. Only toplevel define does an assignment
<nalaginrut>xelxebar: see r7rs 5.3.2. Internal definitions
<amz3>meh
<OrangeShark>happy friday
<OrangeShark>amz3: xelxebar: I think internal defines get inlined in Guile, I am not sure about let bindings
<amz3>happy friday OrangeShark
<OrangeShark>how are you doing amz3?
<OrangeShark>working on anything interesting?
<amz3>well... not really, I am trying to do reach out people about a project of mine that is similar to my work on wiredtiger
<amz3> https://news.ycombinator.com/item?id=15618374
<amz3>to try to understand if there is people who find the project useful
<OrangeShark>oh a graph database
<amz3>yes
<OrangeShark>graph databases seem interesting but I have never had the chance to look into them. I remember going to a conference and watching one of the tracks where they had a bunch of presentations related to graphs or graph databases
<amz3>the guile version is much more powerful, because it support multiple threads but here I try to find out whether people would like to use it for instance if it had a REST API
<OrangeShark>right now it has to be interacted with through python?
<amz3>Once I know what people need, I will do it in Guile
<amz3>OrangeShark: yes, it's library
<amz3>+a
<amz3>At the very beginning, I wanted to use it to interact with conceptnet, but I don't know how to use conceptnet so I have no good usecase for it
<OrangeShark>one thing I wanted to try using a graph database was for a knowledge graph
<amz3>yes, that's what conceptnet, it's a Knowledge Base of some sort
<amz3>but then the question remains, what do you do with the KB?
<amz3>one possible use, is to answer questions
<OrangeShark>yeah, you have to find out a use for that knowledge
<OrangeShark>I was thinking a sort of personal assistant can use a knowledge graph that it builds itself
<amz3>I sent at least a mail to 100 persons from github followings I hope my email don't get banned
<erispre>Hi all! A quick noob question. While trying to construct a circular list, I stumbled upon the following. I tried (define myl '(1 2)) and then (set-cdr! (last-pair myl) myl). This gives me an error message, saying that the first argument of set-cdr! should be a mutable list. However, when I do (define myl2 (cons 1 (cons 2 '()))) and then (set-cdr! (last-pair myl2) myl2), everything works fine. Does this mean
<erispre>that '(1 2) and (cons 1 (cons 2 '())) are actually different objects in guile?
<amz3>AFAIU '(1 2) is literal list
<erispre>amz3: Yeah, but that should give me the same thing as (cons 1 (cons 2 '())), right? I am picking up some things on the Google about mutability, but afaict from the manual, all cons cells are mutable in guile...
<amz3>literals are all immutables
<amz3>that's the difference
<amz3>if you write (cons 1 (cons 2 '())) it's different from '(1 2)
<amz3>also:
<amz3>scheme@(guile-user)> (eq? (cons 1 (cons 2 '())) (cons 1 (cons 2 '())))
<amz3>$1 = #f
<amz3>erispre: ^
<erispre>Ah, I see! cons always allocates a new (mutable) pair, whereas all literals are the same object. That's why they have to be immutable. Got it!
<erispre>I hate mutability anyways, but it's nice to understand!
<erispre>Thank you!
<OrangeShark>erispre: if you want a mutable list, use (list 1 2)
<OrangeShark>that creates a new list every time. The issue with using '(1 2), there is only one of these in memory. So if you modified it, every time you use '(1 2) it would be the modified value.
<erispre>OrangeShark: Check! As a suggestion: perhaps there should be a remark about the inequivalency of '(1 . 2) and (cons 1 2) in the reference manual, in section 6.6.8. It does say that cons returns a different object each time, but it doesn't say anything about the need for mutability under set-car! or set-cdr!.
<OrangeShark>erispre: yeah, I think this was only added in 2.2. You can actually modify them in 2.0 and it gave you some unexpected results...
<erispre>Coming from pure functional languages, I assumed that set-cdr! would allocate a new pair, and update the bindings accordingly when operating on a literal, as mutability is not a thing there.
<erispre>OrangeShark: Then this is definitely a better way! This is why I say: "Death to mutability." :P
<OrangeShark>erispre: the problem with that, is that set-cdr! is expected to mutate it. Can you imagine how you would have to deal with (set-cdr! (last-pair '(1 2 3 4 6) 5)
<erispre>OrangeShark: Yeah, that would be awful. :P However, in this case, as there is no binding and there is no definite return value for set-cdr!, this particular case would not be a problem, I guess. I see, however, how something like (define myl '(1 2 3 4 6)) (set-cdr! (last-pair myl) 5) would be a huge problem, as you would have to allocate a new pair for the last element, and backtrack any bindings to the same
<erispre>literal (or even worse, all bindings that occurred within any subexpression of the call to set-cdr!). The computational cost in the runtime could be immense, not to mention the way you would have to modify the syntax tree to allow for this backtracking... I definitely get you!
<dsmith-work>Happy Friday, Guilers!!
<cmaloney>\\o
<janneke>o/
<sneek>janneke, you have 1 message.
<sneek>janneke, OriansJ says: that I have a special surprise bubbling up at the moment. :D
<janneke>ACTION wants to know more, tell me, where are you OriansJ ;-)
<janneke>sneek: later tell OriansJ: a surprise bubbling...that sounds just great!
<sneek>Will do.
<janneke>sneek: botsnack
<sneek>:)
<manumanumanu>So... Moving a file? Should I just use rename-file and
<manumanumanu>be explicit about the move-to name?
<bavier>manumanumanu: yes
<androclus>Hey, all. I am looking to access a firebird database via guile. i see that guile-dbi has several drivers, but not for firebird. Any recommendations, before I go off and contemplate writing a Firebird driver for guile-dbi?
<rekado>ACTION has never heard of a firebird database
<androclus>rekado: Yeah, it's a great db. An open-source fork of the old Interbase (Borland, later Embarcadero) db, but completely re-written. Small, light, SQL compatible, very high reliability (way better than mysql), etc. They're going to include the 'embedded' version of FB in the next LibreOffice, I hear. https://firebirdsql.org/
<androclus>BTW, I could also ask a broader question: If you want to access *any* db via guile, is guile-dbi the way to go? Or is there some newer/better API that folks are gravitating to?
<androclus>sorry, i had to sign out. if anyone answered my previous question, could you answer it again please? :-)
<rekado>androclus: I don’t know of any alternative to guile-dbi as an adapter for many different database engines, but I don’t do much with databases anyway.
<sirgazil>Hi! Do you know of any way to detect death code in your programs (like procedures defined but never used)?
<androclus>rekado: okay, thx :-)
<rekado>sirgazil: maybe code coverage tools can be used to this end: https://www.gnu.org/software/guile/manual/html_node/Code-Coverage.html
<sirgazil>rekado: Oh, I'll take a look. Thanks!
<dsmith-work>Heh. The only time I've heard of "firebird" was when "firefox" wasn't allowed to use that name.
<rekado>sirgazil: it’s for test coverage, but maybe it can be co-opted for checking for dead code
<amz3>androclus: guile-dbi is still what is used by artanis
<amz3>androclus: but it's recommended to move away from C ffi and use the new dynamic ffi
<amz3>androclus: so if you are going to write bindings for firebird, you have to look dynamic ffi in the manual
<androclus>amz3: thanks for that big heads-up. i am new to guile, and my c is rusty, so writing this will involve making a lot of mistakes.
<androclus>i see it here: https://www.gnu.org/software/guile/manual/html_node/Dynamic-FFI.html
<androclus>so i'll look into it
<happy_gnu[m]>Hi \\o/
<sirgazil>Howdy, happy_gnu[m] :)
<amz3>héllo happy_gnu[m]
<happy_gnu[m]>I have a question for you
<happy_gnu[m]>How do you organize your ideas before coding?
<happy_gnu[m]>I mean, you say OK I will write X program.. What do you do?
<happy_gnu[m]>Start an org-mode buffer, or something?
<amz3>I look up the internet for articles about the subject
<amz3>I read code
<happy_gnu[m]>Or you start coding right-awy
<amz3>I sketch some data model on paper
<sirgazil>happy_gnu[m]: I write prose and draw first (if it's GUI)
<happy_gnu[m]>Ohh
<happy_gnu[m]>sirgazil: so prose is a description of the program?
<sirgazil>yes
<happy_gnu[m]>amz3: what is a data model
<amz3>basically the datastructure to comes into play in the app
<OrangeShark>happy_gnu[m]: I just code away but that doesn't usually create good results...
<happy_gnu[m]>OrangeShark: I know what you mean..
<amz3>happy_gnu[m]: OrangeShark I do that too
<OrangeShark>just being able to develop while testing ideas in the REPL
<OrangeShark>you can play around with the code more
<happy_gnu[m]>So coding is like writing?
<happy_gnu[m]>Not like an architect
<amz3>yes, in the end the code is the only "proof"
<happy_gnu[m]>Architect usually designs whole house before building
<OrangeShark>it probably depends on what kind of project you are working on
<happy_gnu[m]>Writer writes a book, then edits a lot and a lot
<happy_gnu[m]>Until is ok
<amz3>happy_gnu[m]: writer and coder do the same thing actually
<sirgazil>Yes, I think it depends on the project.
<OrangeShark>there is a book called Code Complete that talks about metaphors like this
<amz3>happy_gnu[m]: what do you want to code?
<Ober>written by an MS dev
<sirgazil>happy_gnu[m]: Yeah, did you come up with something to program? I read you were looking for ideas.
<OrangeShark>like one for building software is when you build a dog house is different then building a real house
<sirgazil>So it depends on the final user too :)
<happy_gnu[m]>I don't know
<happy_gnu[m]>I was just curios
<happy_gnu[m]>I usually think I have an idea
<happy_gnu[m]>I write a wish list
<happy_gnu[m]>But the more I code the more functions helpers I create
<happy_gnu[m]>Before I realize it I have a lot of spaghetti code all everywhere
<amz3>it will be easier to discuss that point with real code under the nose
<happy_gnu[m]>So I was curious on what the experts (you guys) do
<amz3>one basic strategy is to regroup together procedures into some categories
<sirgazil>happy_gnu[m]: Oh, you were asking the experts... Then I will just sit in the corner :)
<amz3>like MVC for GUI application where MVC stands for Model View Controller
<happy_gnu[m]>sirgazil: oh come on :p
<OrangeShark>eventually that will happen to code as you continue to develop. That is why you eventually have to refactor your code to reorganize it.
<sirgazil>Yeah, I'm actually cleaning some spaghetti right now, from a year ago.
<happy_gnu[m]>I see..
<amz3>happy_gnu[m]: maybe your code is not spaghetti
<happy_gnu[m]>MVC looks very interesting
<happy_gnu[m]>OK I will write a simple game
<happy_gnu[m]>And I will show you my code
<happy_gnu[m]>So you can tell me what I am doing wrong
<ugoday>Hi, channel. Could you please help me with getopt-long.
<ugoday>I want to specify args as a non negative integer.
<ugoday> http://paste.lisp.org/display/360208
<ugoday>like this
<ugoday>My expectation: when a user starts progranm like "prog -n 7" it launches the predicate function check-num, that checks is it proper number.
<ugoday>but when I tried it, I got:
<ugoday>ERROR: ERROR: Wrong type to apply: check-num
<ugoday>so, how to specify a predicate properly?
<ugoday>and how about nameless positional argumens like "prog file1 file2 file3"?