IRC channel logs

2014-11-11.log

back to list of logs

*davexunit is working on a scene graph for 2d/3d graphics
<davexunit>I'm tempted to use a doubly linked tree structure, but I know that's probably bad to do.
<nalaginrut>morning guilers~
<nalaginrut>seems Guile consume more memories than php...
<ArneBab>nalaginrut: what’s your testcase?
<ArneBab>(moin ☺)
***mario-go` is now known as mario-goulart
<nalaginrut>ArneBab: there's no testcase yet, but I checked the programs on my server
<nalaginrut>guile programs take 2.2% mem
<nalaginrut>others are almost 0
<nalaginrut>or 0.1
<nalaginrut>I haven't gotten a chance to research why
<nalaginrut>even a persistent hash-table won't take 200M IMO
<nalaginrut>in my case
<nalaginrut>BTW, I think hash-table will waste too many memories when it grows to a big one, maybe I should try rbtree, but it's no hurry
<ArneBab>nalaginrut: I don’t see a huge resource usage - but it’s possible that PHP is highly optimized for memory consumption
<ArneBab>(because it is provided by webhosters for whom less memory means more virtual servers to sell per physical server)
<nalaginrut>it's not a problem yet, in many cases, users may have methods to reduce the consumption
<nalaginrut>but the performance of bdw-gc is a mystery for me
<jmd>I have got a procedure from a string: (call-with-input-string "(display (* 3 4))" read)
<jmd>how can I execute that procedure?
<nalaginrut>jmd: eval-string
<nalaginrut>(eval-string "(display (* 3 4))")
<nalaginrut>or (call-with-input-string "..." primitive-eval)
<jmd>The thing is, I need to process it before I evaluate it. I could of course process it as a string, but it would be easier to break it into its individual symbols first.
<ArneBab>jmd: let me check
<ArneBab>(primitive-eval (call-with-input-string "(display (* 3 4))" read))
<nalaginrut>ah, my mistake ;-P
<ArneBab>nalaginrut: I use something similar in wisp ☺ (there I map primitive-eval on a list of lists of symbols)
<nalaginrut>ArneBab: btw, is wisp a srfi now? ;-)
<ArneBab>nalaginrut: not yet, but last sunday I finished the scheme-only implementation which uses (read) where possible, and that was the final piece I needed for the SRFI
<ArneBab>nalaginrut: so I plan to submit it this week or next week
<taylanub>jmd: reading "(display (* 3 4))" will give you an s-expression, not a procedure. or did you mean something else?
<nalaginrut>I don't know the procedure of srfi, but maybe someday I'll submit one for SQL
<nalaginrut>;-)
<nalaginrut>or maybe not directly SQL layer
<taylanub>there's a PostgreSQL library in R7RS by the way, using SRFI-106 for unix sockets: http://compassoftime.blogspot.jp/2014/11/postgresql-for-r7rs-scheme.html
<taylanub>jmd: reading "(display (* 3 4))" will give you an s-expression, not a procedure. or did you mean something else? (dunno if you previously received my message)
<jmd>OK. How can I convert an s-expression into a procedure.
<ArneBab>bbl
<taylanub>jmd: one could wrap it in (lambda () <sexpr here>) like by doing (list 'lambda '() the-sexpr) and then eval the resulting sexpr, but that's quite "dirty" I think. there might be a better way to do what you want.
<jmd>So what then is the purpose of an s-expression?
<taylanub>it's essentially a data format, like JSON. if you're doing intra-process communication, then you can just pass around procedure objects directly. if doing inter-process communication, you could invent a suitable data format / language for the task (based around sexprs) and implement that. if the data *only* comes from trusted sources, then you can just use Scheme code as that language meaning
<taylanub>you use 'eval' on what the user gives you, so you don't have to invent a sublanguage.
<taylanub>if you're already using 'eval' and just wanted to wrap a sexpr in something that will eval it on demand, then you could simply do: (lambda () (eval the-sexpr))
<taylanub>this won't turn the sexpr into a procedure per se, but it will give you a procedure that evaluates that sexpr when the procedure is called.
<jmd>ok, I will try that. Thanks
<taylanub>jmd: out of curiosity, what kind of program are you writing?
<jmd>I just wanted to be able to pass an expression to a program, and have it executed within the program. But I need to check and possibly mutate that string first.
<taylanub>jmd: why do you need to check and mutate it?
<jmd>Well two reasons. One is security. The other is that it can simplify what the user needs to pass.
<taylanub>regarding the former, I would recommend you to give up on it, or you'll need to study it very carefully. Guile uses "psyntax" for hygiene, which is a hacky system that uses literal vectors to represent "macro-expanded" code which can directly reference any binding in any module. a user can pass such a vector literal directly as code and it will be assumed to be pre-expanded code and executed as
<taylanub>such
<jmd>"psyntax" does not appear in the index of the Guile manual.
<taylanub>for example, open the Guile REPL, enter (define (launch-missiles) (display "missiles launched!\\n")), and then enter the line (#(syntax-object launch-missiles ((top)) (hygiene guile-user)))
<taylanub>jmd: it's an implementation detail and will hopefully be replaced eventually
<taylanub>jmd: and regarding the second point (making things convenient for the user), I would just create a module for the user where some handy procedures, variables, and macros are defined, and eval the user's code in there. that will be most intuitive for someone who knows Scheme, and allow the most flexibility.
<jmd>ok. Thanks for your help.
<jmd>bbl
<nalaginrut>taylanub: ah~thanks! It seems a postgresql specific abstraction layer
<taylanub>yup
<nalaginrut>I've checked archive of SRFI, there's a TODO list, one of the items is generic DB abstract
<nalaginrut>IIRC it's decade ago ;-P
<janneke>if an non-goops function is passed a goops object, how can it test if it is a goops object or not?
<janneke>iow, how do i implement `instance?' without loading goops
<taylanub>that sounds somewhat contradicting. generally a type predicate will be part of an API that defines that type; don't know if GOOPS is an exception.
<taylanub>janneke: why do you want to avoid loading (oop goops)?
<janneke>taylanub: i fear that generics on equal? etc have an impact on performance
<janneke>taylanub: guile-2.0.5 does not have supports-source-properties, and guile-2.0.11 does the right thing in this case
<janneke>how to write supports-source-properties in 2.0.5 (pair? is not enough, i need instance too)
<taylanub>janneke: I suppose you could use (@ (oop goops) instance?), or will that implicitly "load" the module?..
<taylanub>I don't think it will. it would be kind of nasty if it did, I think.
<taylanub>does (oop goops) just define its own `equal?', or how does it normally override equal?
<taylanub>goops.scm does (set-primitive-generic! equal? g-equal?). not sure what that means.
<lloda>looks like overriding to me
<janneke>taylanub: nice
<janneke>taylanub: no idea how it works with equal, there's something kinky there
*taylanub can't find out where set-primitive-generic! is defined
<taylanub>or rather, how it's imported into goop.scm. doesn't seem to be in the standard environment.
<taylanub>oh, goops.c :)
<dsmith-work>Morning Greetings, Guilers
<Chaos`Eternal>i wrote a small piece of code to make system calls and return errno
<Chaos`Eternal>just wonder whether it is thread-safe and solid
<Chaos`Eternal> https://gist.github.com/anonymous/ba60807af2b69be33692
<mark_weaver>that's unlikely to be portable
<Chaos`Eternal>agree
<mark_weaver>it might work on glibc though, dunno.
<Chaos`Eternal>one thread on glibc, it works
<mark_weaver>really, we need to solve this issue in guile core, I think.
<mark_weaver>Here's the ticket: http://bugs.gnu.org/18592
<mark_weaver>the other thing is that Guile's own VM might make some calls behind the scenes that changes errno.
<mark_weaver>with existing versions of Guile, I think the only good solution is to write some C code that calls the C function you want and then immediately fetches 'errno'.
<mark_weaver>maybe the thing to do is to add functionality to 'pointer->procedure' that optionally arranges to fetch 'errno' after making the call.
<Chaos`Eternal>someone wrote in guile's manual says that pure scheme code to make ffi is preferred..
<mark_weaver>I agree, it definitely is preferred.
<mark_weaver>but at present, we don't have a solution to this 'errno' problem.
<mark_weaver>and more generally, we don't have a good way to deal with preprocessor macros, of which 'errno' is an example.
*mark_weaver goes afk
<mark_weaver>or we could just *always* copy 'errno' into our own thread-local variable after FFI calls, and then provide a way to access that saved value.
<mark_weaver>the only reason I don't like that is because it would add some overhead to the FFI, which in theory could be made quite efficient in the future.
<Chaos`Eternal>or we just add another version of pointer->procedure-with-errno, which returns two values
<mark_weaver>yes, I think that might be a good solution.
<mark_weaver>although it might be nicer for it to be an optional keyword argument to the existing 'pointer->procedure'.
<Chaos`Eternal>sound good
<mark_weaver>would you like to work on it?
<mark_weaver>hmm, although maybe we should post to guile-devel about the proposed API and ask for comments first.
<mark_weaver>it occurs to me that there's another possible option: to ensure that 'errno' is never disturbed by the VM/evaluator.
<mark_weaver>hmm, well, users would still need to block asyncs.
<mark_weaver>maybe it's too ambitious for the short term.
<Chaos`Eternal>mark_weaver, it sounds too ambitious to me to work on guile code itself, i am not familiar with c.
<mark_weaver>Chaos`Eternal: okay, no worries, I can do it.
<mark_weaver>wingo: do you have any thoughts on how best to allow 'errno' to be accessed when using the Dynamic FFI ?
<mark_weaver>Chaos`Eternal and I were thinking that maybe 'pointer->procedure' should accept an optional keyword argument that, when given, returns a procedure that returns 'errno' as a second result.
<wingo>mark_weaver: wdyt about an errno function in (system foreign) ?
<mark_weaver>wingo: I worry that something else may change 'errno' between when the C function is called and when 'errno' is fetched.
<wingo>like allocation?
<mark_weaver>allocation, or system asyncs, finalizers, the VM, who knows?
<wingo>hah, good point
<wingo>errno is such a nutty interface
<wingo>sure, i guess, that solution (multiple values) is less bad than others i can think of :)
<mark_weaver>I agree that it would be ideal for us to guarantee that 'errno' is never disturbed behind the scenes, and maybe some day we can get there.
<mark_weaver>cool, thanks!
<wingo>another option is to throw an exception
<wingo>given that if errno is set, probably the result is useless
<wingo>i.e. scm_syserror() right after the ffi call
<mark_weaver>hmm
*wingo just thinking out loud, no real opinions here
<wingo>it would be somewhat similar to what other errno-using interfaces in guile do
<wingo>but probably you can't do it for all functions
<wingo>because you don't know that the ffi call actually sets errno
<mark_weaver>right
<wingo>so you still need the flag somehow
<mark_weaver>also, I suspect that in the future, we'll be able to make FFI wrappers extremely efficient, and I'd rather not add "check errno" to the list of things it always does.
<wingo>right -- but it would also be incorrect to always check errno :)
<wingo>you can only check it if you know you did something that sets it
<wingo>afaik?
<mark_weaver>true, and that's the more compelling argument :)
<mark_weaver>right, 'errno' could be left over from some earlier call.
<mark_weaver>if we add a keyword argument to 'pointer->procedure' for this purpose, we could support an optional mode that raises an exception if errno is non-zero.
<mark_weaver>and another mode that simply returns the value of errno.
<mark_weaver>(as a second return value)
<mark_weaver>wingo: FYI, we have a ticket for this 'errno' issue: http://bugs.gnu.org/18592
<wingo>cool
<wingo>not much more info there tho
<mark_weaver>yeah, just mentioning it as a place to add further info/discussion.
<civodul>Hello Guilers!
<stis>evening folks!