IRC channel logs
2013-12-04.log
back to list of logs
<ijp>okay, but that just sounds like a bug rather than a usecase for eval-when <ijp>zzach: by and large, scheme just isn't compatible <dsmith-work>civodul: Hmm. The guile-wm script has a shebang pointing to /usr/bin/guile <ijp>especially if you want to do exotic stuff like robust file opening <ijp>can you show me the code that is erroring? <dsmith-work>civodul: Yeah, I get xcb/xml/struct.scm:56:20: In procedure struct_vtable: Wrong type argument in position 1 (expecting pair): #f <zzach>ijp: it seems to work if everything is pasted into the repl. It would be OK if there were a command like "insert into repl". <ijp>as innocent as it sounds, that's not always a great test <ijp>repls are by and large treated specially <zzach>ijp: will try to isolate the part of the code and post it later. <ijp>is it big? work-related? <civodul>dsmith-work: bad news! i don't think he's on IRC, is he? <dsmith-work>civodul: Maybe not often, but ISTR someone in here mentioning guile-wm <shanecelis>davexunit: Going all right. I'm dabbling with an iOS app, and working with Xcode is killing me. <davexunit>shanecelis: pretty well. made some neat progress with guile-2d these past few days. <davexunit>wrote some cool functional reactive programming stuff <shanecelis>davexunit: Cool. I'm interested to see what that looks like in Scheme. I've only seen it in Haskell. <davexunit>I built a simple API and some primitives to work with. <davexunit>and with a few extra lines I can declaratively specify that a sprite moves around the screen when the arrow keys are pressed. <davexunit>I would be deep in callback hell using the more traditional callbacks approach. <shanecelis>davexunit: Because it almost looks like you're registering a callback. <davexunit>quit-on-esc is kind of a gross hack actually <davexunit>the idea is that you let the FRP API take care of the side effects for you and the user writes everything in a more-or-less purely functional style. <shanecelis>ok, I'm trying to grok this: (time-delay (* (- follower-count i) 10) move) <shanecelis>So, we just grab whatever the value of move was some time T ago? <davexunit>when a new value is received for "move", delay propagation for some amount of time. <davexunit>ignore the math (* (- follower-count i) 10), that's not so important. <davexunit>it effectively grabs the value some time T ago, but it's actually delaying the event from propagating rather than reaching back in time. <shanecelis>Cool. So is it the case that at first all ghosts are stacked on top of one another? <davexunit>and once you move around, they trail one after the other. <davexunit>each subsequent ghost delays 10 ticks longer than the one before it. <davexunit>when the ghost moves, it takes 80 ticks for that event to make it to the last follower. <davexunit>yeah you can just keep composing signals together to get what you want. <shanecelis>I like the idea of having the core game, then just throwing a ton of visual junk on top of it without having it clutter the actual mechanics. <davexunit>I plan to use this FRP stuff for updating the game model as well as drawing it at some point. <kurohin>yes! finally I understand what I am doing wrong. mark_weaver: I sent an update on the bug I submitet yesterday that it should be closed. <ArneBab>why do I see gibberish on the shell when I run a script containing only (display "ÄCẞO∂Σℕ∪τφμο")(newline) <ijp>ArneBab: locale issue <ArneBab>nalaginrut: I wrote a fun file transcoder: write any file into text files repeating an ASCII-logo over and over again (with the content encoded into the logo) and turn those files back into the original content. <ijp>*grumble* *moan* stupid computer <ijp>(setlocale LC_ALL "") <ijp>there is a good reason why you need to do this, but I've completely forgotten it <ijp>it'll be on the ml somewhere <ArneBab>possibly this ensures that scripts act the same everywhere - except if the programmer explicitely requests otherwise. <nalaginrut>IIRC last time the same issue was raised because of Chinese <ijp>the exact coding scheme isn't really the issue <ArneBab>did you see wingo ’s rant about the universal intermediate representation language proposal? <ArneBab>the proposal he linked to actually contained a line like this: <useless requirement> “in order to protect intellectual property rights” <ijp>ArneBab: I think it's probably a C standard thing, using the C locale by default <ijp>(info "(libc) Setting the Locale") <ijp>"A C program inherits its locale environment variables when it starts up. This happens automatically. However, these variables do not automatically control the locale used by the library functions, because ISO C says that all programs start by default in the standard `C' locale." <ijp>there are two kinds of standards: the ignored, and the actively harmful <ijp>nalaginrut: I just looked back at that thread, and the problem there is with command line arguments <ijp>they get converted by guile, *before* there was a chance to make the setlocale call <ijp>dunno how that got resolved <ijp>maybe, but I am not seeing one <ijp>yeah, so could I, quicker <nalaginrut>the bug is that Guile will crash if the args contains special character <nalaginrut>but if you want to show it correctly, setlocale is needed <ijp>no, even with setlocale <ijp>test.scm (setlocale LC_ALL "") (write (command-line)) <ijp>("/tmp/test.scm" "å®\\x8cç\\x92§") <nalaginrut>setlocale will detect your current env for locale <ijp>it is a utf-8 locale <ijp>what version of guile you running? <ijp>perhaps I'm just on a bizarroGnu system <ijp>weird, because mine is newer <ijp>I don't think that is very likely <ijp>and it would have made no sense for it to have had one <ArneBab>nalaginrut: and I don’t have zh_CN, but de_DE.UTF-8 <ijp>I'm looking through the git log now <ArneBab>nalaginrut: I just did: ("/tmp/test.scm" "完璧") <ijp>I'm looking at what I think is the right patch now <ArneBab>ijp: are you sure that .utf8 works? I think I had to set .UTF-8… <ijp>I can fiddle with it all I like, it isn't having an effect <ijp>meh, this has never been an issue anyway <ArneBab>what do you have in /etc/locale.gen ? <ArneBab>the all-important line in mine is de_DE.UTF-8 UTF-8 <ijp>I don't have that file <ijp>probably a debianism <ijp>or rather its removal a fedoraism <ijp>nalaginrut: short, but uninteresting story <ijp>turns out using a computer in a language you are trying to learn helps speed up learning, who'da thunk it <ijp>I'm willing to believe this bug is fixed since I'm looking at the patch <nalaginrut>but since I'm learning Latin, I found set locale to "latin-1" is non-sense... <ijp>I have no idea what the correct code for latin is <ijp>well, probably not, since one of them is a country code <ijp>I think the language code is probably la_ <ijp>if only there was some organisation for assigning names and numbers I could get this information from... <ijp>hmm, the vatican city could have it's own locale <ijp>well, I was just inferring it <ijp>ArneBab: where is this rant? <nalaginrut>I wish I can finish Latin soon, and take up German <ijp>I have spoken german on exactly one occasion since leaving high school, and it was by accident <nalaginrut>my free time becomes compact since I have a baby <ijp>headphones on, not swearing <ijp>these are not nearly long enough to qualify as rants <ijp>if you can't go on for an hour unprompted, it's not really a rant! <ArneBab>scheme question: If you use let-recursion, how do you avoid repeating youself in the call to the let-“function”? <ArneBab>if the let has 4 parameters, and 2 are often the same (though not always), the calls look quite similar <ijp>if you don't want to use a fancy loop macro, then there isn't really much you can do <ArneBab>(let loop ((foo 1)(bar 2)(baz 3)) (if (= 1 foo) (loop 2 2 3) (if (= 2 bar) (loop 2 3 3) (if (= 3 baz) (loop 2 3 4) 5)))) <ArneBab>could I define a default call - something like a macro which inserts the default parameters? <ijp>you can define whatever you like *ArneBab seems to have forgotten that this is scheme ☺ <ijp>rather than a named let, you might try a define* or letrec + lambda* <ijp>and if it gets really complicated you'd be better of with a few mutually recursive functions or state than one loop <ArneBab>In 3 of 5 cases I call it with the first 2 parameters the same. Is there a *nice* way to simplify this? <ArneBab>ijp: would it help you to see the scheme equivalent? <ijp>and it's the kittify function you are struggling with? <ArneBab>ijp: it works, but it feels redundant… <ArneBab>nalaginrut: I think he does not believe in inter-compiler IR <ArneBab>nalaginrut: like making PyPy, Java and Guile use the same IR… <ijp>hmm, someone once asked why named let* didn't exist, and I've thought of a actual use for a function with that name <ijp>it wouldn't have let* semantics, but lambda* semantics <ijp>and keywords and rest <ArneBab>actually here I think I would actually need something more: a macro which adds the default recursion for some parameters. <ArneBab>in a for-each loop, the default recursion is “go to the next parameter”. In let-recursion I have to explicitely give that everytime. <ijp>right, which any fancy loop macro will do <ijp>but I think you might be able to get away with less here <ijp>hold on, I'm playing with it <wingo>nalaginrut: a standard IR is only interesting if you have a bad compiler and you want to take advantage of a good compiler <wingo>or if you want to make some proprietary extension <nalaginrut>well, inter-compiler IR is non-sense and hard to do <wingo>nalaginrut: but if you are in the business of making a good compiler for a specific language, then a common IR is a hindrance <wingo>much better to share ideas rather than code or data in this instance <ijp>ArneBab: you have no idea how much better that code looks when I turn those ifs into a cond <nalaginrut>I like a generic VM to hold various languages, sounds a common IR, huh? <nalaginrut>not a generic IR could be used between various compilers <ijp>nalaginrut: the analogy is not bad <ArneBab>ijp: I can imagine, I just wasn’t sure how to do that perfectly. <nalaginrut>besides, I expect a nice way to write language front-end, although many VM could hold various languages <ArneBab>ijp: I’m still in python-land when it comes to using cond and if… <ijp>ArneBab: well with python, you'd get consistent indentation with else/if so same applies <ijp>anyway, my idea didn't pan out, due to a slight oversight on my part about how optionals work <ijp>but I'll do a quick rewrite with foof-loop, and show you how that would change things <ijp>by changing the default way the loop updates you could further reduce code noise <ijp>think of it as a keyword argument update <ArneBab>so it reuses the last way the argument was called? <ijp>this is not a normal named let, you understand <ijp>foof loop is kinda like if named let and do got together, and bought some keyword toys for the freakiness <ijp>I don't think riastradh would be particularly fond of that review <ArneBab>what happens if the first continue isn’t called first? since the macro still sees it, does it take its call? <ijp>if you don't call continue it doesn't continue <ArneBab>I mean, what happens if nums is '() at the first iteration? <ArneBab>(so the first cond does not get triggered first) <ijp>oh, you mean in the one where I only have two arguments to continue? <ijp>it uses the previous value <ArneBab>so potentially the first value? (not calling the function) <ijp>but if you had, say (i 0 (+ i 1)) at the top instead of (i 0), then it would loop by adding 1, rather than repeating <ijp>I'm not going to try and give a tutorial over IRC :) <ijp>it wouldn't be too difficult to write, say a toy named-let, that filled in defaults positionally <ArneBab>ijp: I just tried loading foof-loop and failed → (use-modules (wak foof-loop)) ← what’s wrong? <ijp>probably that guildhall versioning problem again <ijp>ArneBab: got an error message for me? <ijp>try reinstalling (no seriously) <ArneBab>is it in guile or do I need to reinstall it separately? <ijp>not in guile, *guildhall* <ArneBab>that explains it (I did not use guildhall yet) <ijp>you could give srfi :48 a whirl <ijp>that one is in guile <ArneBab>ijp: that uses two-character escapes, right? <ArneBab>ijp: I can’t really use two-char escapes in an ascii-art template… <ArneBab>ijp: but I now at least switched to cond ☺ <ijp>unknown_lamer: foof loop is more iterate than loop <ijp>because it's the obvious name for a loop macro <unknown_lamer>Personally, I always found the syntax of loop nicer, but I'm weird. <ijp>shivers did it too, though as far as I know that code never got released <wingo>dunno why shivers bothered talking about it if he never released code *wingo has never really gotten the hang of loop macros <unknown_lamer>wingo: you encounter imperative looping a lot more in CL than in scheme... since CL is often more imperative <wingo>we need to start inlining map and for-each <unknown_lamer>there, loop is handy. And, like format, quickly grows out of control and turns into unreadable sludge if you're not careful <ijp>like almost instantaneously <ijp>like roaches or justin bieber fans <ijp>as for 'do', I honestly cannot remember the last time I used it <ijp>fmt is nice, but it's often not worth it *unknown_lamer has written some format strings that achieved sentience before <ijp>ah syntax-rules, I had forgotten how hairy you get with little to no effort *ijp throws away adhoc loop macro <ijp>thought for the day, never drift to the right <ijp>doubly so if you are driving in the UK *ArneBab needs to do some non-learning work now. <ijp>when you want me to be unhelpful, /join #emacs <unknown_lamer>huh, I'm not missing something... guile doesn't have a pi constant does it? *wingo trained as an engineer ;) <Fulax>(define pi (* 4 (atan 1))) ? <wingo>Fulax: you on the other hand must be a mathematician ;) <Fulax>It's just I can't remember any information, only the way to get the piece of information I need <DerGuteMoritz>I always liked (/ 22 7) but (* 4 (atan 1)) isn't actually that hard to memorize <wingo>besides, (/ 22 7) is a rational <unknown_lamer>it's just a bit of a pain to work with radians without a pi constant ha <wingo>i guess that's like defvar tho <wingo>there is also define-inlinable if you want that <unknown_lamer>define-once is not defvar, the manual is a liiiieee (defvar also marks the name special) <unknown_lamer>define-inlinable is probably sane, I'm assuming the partial evaluator doesn't optimize away global binding references eh <unknown_lamer>ha, daniel hartwig is an hcoop member and I accidentally put off one of his support requests while hacking on figl... maybe he will forgive me <unknown_lamer>but he's using gitorious instead of our git server! bad member >:O <unknown_lamer>hrm, I've discovered that I have a lot of code that makes a new array with the same shape and type as an existing array... any ideas for a sane name for doing that? <unknown_lamer>vs repeatedly doing (apply make-typed-array (array-type vec1) *unspecified* (array-dimensions vec1)) <unknown_lamer>I was thinking make-similar-array or make-congruent-array but those mathematicians had to go and define meanings for those words <lloda>although the argument is not a shape... <unknown_lamer>but there's also an (array-shape ...), so the name is slightly ambiguous. Another idea was (make-array-with-shape ra) <unknown_lamer>but I also want to clone the type (dealing with floating point transformation matrices that end up being passed to opengl) <lloda>make the type a keyword arg that defaults to the type of the array <lloda>(define* (make-array-with-shape A #:key (type (array-type A))) (apply make-typed-array type *unspecified* (array-dimensions A))) <unknown_lamer>hrm... (define* (make-array-with-shape ra #:optional (fill *unspecified*) #:key (type (array-type ra))) <lloda>actually I have $ aliased to array-dimensions, then you can use ($ A) directly <lloda>array-dimensions is entirely too long for something that's used so often <unknown_lamer>my argument for making the fill optional instead of a keyword is ... numerics. I end up filling all my arrays with 0, since I (assume, maybe I'm making an ass of myself) that *unspecified* triggers a shortcut that doesn't clear the memory <lloda>but then you have to read them <unknown_lamer>especially when you realize there's no reason to adhere to the artificial line length limit of 80 chars <lloda>that's a matter of taste I guess <lloda>for using 0 instead of *unspecified*, do you need to clear the memory? <unknown_lamer>I started doing closer to 120 or so after inheriting a bunch of SML that used long lines and realized the world didn't end now that my monitors are all higher res than 640x480 :D <lloda>then you can't use *unspecified* <unknown_lamer>a lot of times for gl math you need a blank array, and then mutate a few elements <lloda>that explicitly doesn't clear anything <unknown_lamer>lloda: that's what I was assuming, but I figure I should make the array ops generic <unknown_lamer>someone might find use for them outside of computing transformations and all <unknown_lamer>and it clearly does not make sense to use 0 for e.g. a char array <lloda>I think *unspecified* is the best default, but it's not too bad to give 0 explicitly when you do need 0 <lloda>I know many libraries default to fill-with-0, even low level ones such as std::vector in C++ <lloda>(0 or 'default element for the type') <lloda>but if you care about the value, then you should give a value <lloda>there's nothing special about 0 <unknown_lamer>C++ ... yech. I actually had to dig out my well-worn copy of the stroustrup c++ book the other day <unknown_lamer>who knew I'd be consulting the appendices for vital information ten years later <lloda>I know I'll never understand the overload resolution rules, so I'll have to keep my copy forever :-/ <mark_weaver>ijp, ArneBab: fwiw, the locale is now automatically set by the 'guile' executable on the 'master' branch, and will be in Guile 2.2. <mark_weaver>there's also an environment variable that controls whether it is done automatically. <unknown_lamer>lloda: I keep mine around because I learned how to program from it, basically <wingo>i was thinking copy-on-write somehow <davexunit>mark_weaver: any chance that the REPL read-wrapper patch can make it in? :) <civodul>mark_weaver: would you feel like taking care of it? <civodul>i could help with the bugs i reported, for instance ;-) <mark_weaver>the interface doesn't feel very clean to me. there may be a better way to do it. <mark_weaver>anyway, we'll wait at least 2 weeks before the release, so there's time to discuss.