IRC channel logs

2018-06-28.log

back to list of logs

<chrislck>Just a question about LISPy programming in general...
<chrislck>In contrast to C/python, scheme allows objects to contain anything... numbers/symbols/lists/lists-of-lists
<chrislck>So these objects being passed as argument to functions get passed around until they're actually used
<chrislck>which means a deep unknown function will actually do e.g. (define x (+ a b)) assuming a and b are numbers
<chrislck>but if the originating top-level function doesn't insist that a and b are numbers, it becomes difficult to debug
<chrislck>I guess this is about typed-scheme programming - what do guilers actually do to assist? enforce 'contracts'? e.g. (define (func a b c) (if (not (number? a)) (throw "a must be a number") ...) ?
<terpri>chrislck, i usually don't do explicit type-checking, and just rely on lower-level operators and macros (record accessors, pattern matchers, etc.) to signal an error if the types are wrong. imho that style works well enough in mostly-functional programs, where delaying type checks won't cause side effects
<terpri>or sometimes i use goops, and types are checked during method dispatch
<chrislck>thanks... it does require a lot of discipline and documentation of these deep functions... this can be a problem when the module is not well documented, and the variable names keep getting changed
<pierpa>do not use modules which are not well documented
<wingo>good day
<civodul>hello wingo!
<civodul>i added a printf in scm_error_scm and we see interesting things while building: https://paste.debian.net/1031128/
<civodul>some of this must be (false-if-exception (module-ref ...)) i guess
<wingo>civodul: that does look weird!
<civodul>the out-of-range bv-u8-ref seems to come from: (false-if-exception (string-table-ref bv name))
<civodul>wingo: if i mark the whole stack conservatively, from stack_bottom to stack_top, the crashes seem to disappear
<civodul>(i wonder why i didn't start with this test...)
<wingo>that's good at least :)
<wingo>so you think that we should set vp->sp atomically in some way? at least compiler barriers
<civodul>the brute-force SEQ_CST things that i used didn't help
<civodul>so it might be something else
<wingo>civodul: another thing to test: what if you mark from stack_bottom to sp conservatively, and precisely between vp->sp and stack_top
<civodul>good idea
<civodul>i got a crash (out-of-range vector-ref) when marking conseveratively from stack_bottom to sp, and precisely upwards
<wingo>civodul: btw dunno if you had a diff patch from https://paste.debian.net/1030656/ but that patch didn't cover all the sp manipulations
<civodul>i added a couple more atomics, notably in scm_i_vm_mark_stack
<wingo>that's not needed either
<wingo>scm_i_vm_mark_stack is run when the world is stopped
<civodul>right
<wingo>there are other markers but nobody's writing stack pointers
<wingo>i'm thinking mainly when vp->sp is pushed and popped
<wingo>i guess though by setting in alloc_frame and reset_frame you covered that case... humm
<civodul>yeah
<wingo>there are a few cases in vm.c of course...
<wingo>e.g. the scm_call_n things
<civodul>i vaguely suspected subrs at some point, but couldn't find any evidence
<wingo>civodul: ah your patch missed a set of ->sp in alloc_frame, on the path where the stack had to be extended
<civodul>ACTION checks
<civodul>hmm yes
<wingo>ACTION a bit irritated that threads aren't marked from their own stacks :P
<rain1>what do you think of my idea for named args
<rain1>(create-file name contents :temporary=#t)
<rain1>new syntax is :<symbol>=<term>
<wingo>rain1: what does it do? :)
<wingo>is it like #:temporary #t ?
<rain1>someone said dont use boolean parametrs, they make code hard to read
<rain1>"This is mostly solved in languages with named parameter calling (if you use it). Example: createFile(name, contents, temporary=True)"
<civodul>OrangeShark: would you be willing to tag a release of Guile-Git?
<civodul>i think the current state of master would be perfect for 0.1.0 or something
<civodul>return-values does: if (nlocals) RESET_FRAME (nlocals);
<civodul>but the rest doesn't check if NLOCALS is zero
<civodul>we never emit (return-values 0) though, do we?
<civodul>wingo: ↑
<manumanumanu>rain1: well, what does it bring over using lambda* ?
<Copenhagen_Bram>hello, I'd like to learn how to write guix packages so I thought this might be a good place to be lol
<Copenhagen_Bram>for instance what does lamda mean?
<rekado>Copenhagen_Bram: a “lambda” expression returns an anonymous procedure.
<rekado>Copenhagen_Bram: (lambda _ #t) returns a procedure that takes any arguments and returns #t when executed.
<Copenhagen_Bram>what's an anonymous procedure?
<rekado>it’s a procedure without a name.
<rekado>you can bind a procedure to a name, for example: (define square (lambda (x) (* x x)))
<rekado>this means: define the name “square” to be a procedure that takes exactly one argument and returns the square of that argument.
<rekado>we use lambda whenever there’s no point in giving the procedure a name.
<rekado>a Guix package definition is a “package” value that’s bound to a name.
<rekado>in the Guix sources you’ll often see something like (define-public foo (package …))
<rekado>“define-public” is like “define”, but it also makes the value visible to other modules (other than the current file).