IRC Logs for #io Sunday, 2017-02-26

*** psYchotic has joined #io00:29
psYchoticGood evening everyone00:31
psYchoticBesides my earlier question, I was hoping you might be able to help me with something00:34
psYchotichttps://gist.github.com/otaconix/5f77162f9620b6415c369bf2cb2ac17800:35
psYchoticYou may have guessed it: I'm working through the "Seven languages in seven weeks" book, and I was interested in the example where you use the "curlyBrackets" slot00:36
psYchoticand I noticed I can evaluate that code in the REPL, which eventually prints "Map clone do(atPut("Hello", "world"););"00:37
psYchoticbut, when I run the file directly (as in: "io map.io", or in the REPL "doFile("map.io")"), it tells me "Exception: Sequence does not respond to '=>'"00:38
psYchoticwhat's going on there?00:38
pdurbinpsYchotic: hey, I don't know but if you stick around you'll probably get an answer eventually. Good book. That's why I'm here too.01:03
psYchoticpdurbin: ah, nice to see someone saying something. I thought I'd run into a graveyard =)01:05
psYchoticturns out that my operator problem is not so much a problem as the simple fact I misunderstood how they work =)01:46
psYchotichttp://stackoverflow.com/questions/10383065/why-does-the-io-repl-and-the-interpreter-give-me-two-different-values#1038320301:46
jerpsYchotic, i wrote that example for Bruce Tate (the phone book one) ... basically since operators are manipulated at parse time, not eval time, but the code to manipulate is run at eval time, you have to do a file with your operator manipulations first, before anything else01:47
jeri.e., in your map.io, you also have a foo.io, inside foo.io you do the operator table stuff, and then at the top of map.io doFile("foo.io")01:47
jerthen for the rest of map.io, you can use the operator01:47
psYchoticjer: awesome, that confirms what I just now found while googling01:48
jeroh that's what the stack overflow says =p01:48
jersorry didn't click01:48
jerpsYchotic, yeah no worries, i gave Bruce Tate the sample code for that third example in his book01:48
psYchoticWell, then, thanks Chris!01:49
psYchoticoh, no you're obviously Jeremy xD01:50
psYchoticnever mind, I thought I was being clever, but it's obviously late here01:50
jeryeah =]01:52
jerlol01:52
jersorry i'm also watching a hockey game01:52
psYchoticNo worries01:52
psYchoticAs long as I have you glancing at my ramblings: have you seen my question earlier today? The one where I was trying to implement some kind of "cond" construct you'd find in most lisps?01:53
jerah yeah i did see that, try creating a closure inside, which takes an arg position in addition to the current list of arguments, invoke that, and call it recursively01:54
jeri've built one of these before, that's how i did it01:54
jerio chains stacks together, so you won't get a stack overflow until you run out of memory01:54
jerif i could be arsed, i could add tco, but i haven't written code for io's implementation now in years01:54
psYchoticI'm trying to make that work =)02:04
jerpost your code02:08
psYchoticI got it to work02:09
jerah ok02:09
psYchotichere goes:02:09
psYchotichttps://gist.github.com/otaconix/052b980a3fd506e91b92c3bee96b74d502:10
jeryou could simplify that even02:11
jerby making inner take just one arg, a *message* not a call02:11
jerstart it off by passing in call message02:12
jerand then when it itself recurses, have it pass in call message next02:12
jererr s/call message next/message next/02:12
jerassuming you name your param 'message' which you currently have named 'c'02:12
jeroh i shoudl clarify, that changes syntax a bit; instead of being things like: cond(a, 42, b, 12)02:16
jermy way would make it: cond((a, 42), (b, 12))02:16
jeryour way is the right way if you want the former syntax02:17
jermy way simplifies your inner closure but changes your syntax02:17
jertradeoffs =]02:17
psYchoticah, that's why I couldn't get it to work!02:17
psYchoticyour way looks lispier, I guess02:17
jeryeah02:17
jeri have a bad habit of making io code look like other languages =]02:17
jerlet me see if i can find one especially hienous example02:18
jerhaving to hit the wayback machine for this: https://web.archive.org/web/20080626093912/http://blurgle.blogspot.com/2006/09/fun-with-c-dsl.html02:19
jerplease note that the example code that makes that work doesn't work in modern io, that is circa 2008 io where the message data structure looked a bit different02:20
jerMessage next used to be called Message attached02:20
jerand Message next of old doesn't exist anymore (it's basically a while loop checking that next message isEndOfLine)02:20
psYchoticso that's the 40-liner Bruce Tate wrote of02:21
jerexcept it's 20 lines of code02:22
jer=D02:22
psYchoticwas about to say that, indeed, it's much shorter02:22
jereven with the c code, 7 =]02:22
jerto write it in "modern" io (with the new message manip routines) it's probably around 3002:22
jerbut that is a VERY contrived example =]02:24
jeri doubt it'd work for much more than that dsl code02:24
psYchotic=)02:24
jerfrom about 2006-2011 that was basically my focus -- doing weird things with messages =]02:27
jer(and working on the implementation)02:27
psYchoticone more question: what if I have something like a "break" in the "right-hand side" of my cond?02:28
psYchoticbecause something like this doesn't work as I'd want it to: while(true, 1 println; cond(true, break))02:29
jershow me an example of how you'd use it02:29
jerah02:29
psYchoticand I noticed it does work for "if"02:29
jerwell you can't break out an if02:29
jeri guess it depends on how while works, i can't remember02:30
psYchoticno, I mean that it works in this case: while(true, 1 print; if(true, break))02:30
jerlet me look02:30
jerok so if() is implemented very similar to your cond02:31
jerone sec02:31
jerif := method(c, (c == true || c != nil) ifTrue(call evalArgAt(1)) ifFalse(call evalArgAt(2)))02:31
jerthat's if02:31
jerand if you look at the ifTrue and ifFalse implementations, they're this:02:31
jertrue ifTrue := method(call evalArgAt(0)); true ifFalse := method(false); false ifTrue := method(false); false ifFalse := method(call evalArgAt(0))02:32
jeras you can see, the arg evaluation bits are the same02:32
jeras your cond02:32
jerah i see why02:33
jerbecause your inner is broken02:33
jeryou should, after you define it, add a line like this:02:33
jergetSlot("inner") setTarget(call target)02:34
jer(i haven't run that code, haven't had an iovm since 2011)02:35
psYchoticthere's no such slot on Block =(02:35
jeroh wait, yeah we gotta change one more thing02:36
jerone sec02:36
jeryour line 7, you want to change that to: c target evalArgAt(i + 1), and then undo the previous change i had you do =]02:36
jerif that doesn't work, i don't recall02:37
psYchoticI updated the gist to what I guess is what you meant02:39
*** TheMonkey has joined #io02:40
psYchoticbut it still doesn't seem to work, whether I evaluate the argument in the context of the sender or the target doesn't seem to matter much02:41
*** ElMonkey_ has quit IRC02:42
psYchoticI'm going out for a smoke, so I won't be replying for a wee bit02:44
psYchoticaaand I'm back02:53
psYchoticfor the heck of it, I updated the gist to include how I'm trying to use it, because maybe I'm overlooking some other idiocy on my part03:12
psYchotichttps://gist.github.com/otaconix/052b980a3fd506e91b92c3bee96b74d503:12
jerah, ok; so i can tell you what's going on now =]03:18
jerline 1703:18
jerwrap the right argument inside a message(...) and run that in the repl03:19
jeras in:03:19
jermessage("You guessed it!"; break)03:19
jersave that in a slot03:19
jeri.e., x := message("You guessed it!"; break)03:19
jerand play around with x03:20
jerspecifically try feeding it into a method even like if() as one of if's arguments03:20
jeryou'll find the ; is your problem03:20
jeranyway i'm out03:25
psYchoticI still don't understand. What do you think my problem is? Because I don't really care that the "You guessed it" wouldn't get printed, if that's what I think you think is my problem03:25
jergood night03:25
psYchoticah, alright. Thanks for your time!03:25
psYchoticgood night03:25
jerthe problem is you have multiple trees03:25
jerand you're evaluating the root of one, which does try and evaluate all, but the semicolon screws up the object that receives the message03:25
jerif(42, "foo"; break) inside a while loop would almost certainly yield the smae result (again not tested)03:26
jeranyway i really need to head out03:26
jeri'll check back here in the morning03:26
psYchoticcool. Thanks!03:26
psYchoticsame here03:26
*** psYchotic has quit IRC03:32
*** TheMonkey has quit IRC09:13
*** ElMonkey has joined #io09:13
*** Guest52928 has joined #io10:28
*** Guest52928 has quit IRC10:59
*** psYchotic has joined #io12:04
*** psYchotic has quit IRC12:50
*** xmajedz has joined #io19:04
*** xmajedz has quit IRC19:06
*** ElMonkey has quit IRC22:07
*** ElMonkey has joined #io22:14
*** psYchotic has joined #io22:30
*** psYchotic has joined #io23:11
*** psYchotic has left #io ()23:26
*** psYchotic has joined #io23:26

Generated by irclog2html.py 2.14.0 by Marius Gedminas - find it at mg.pov.lt!