IRC Logs for #io Saturday, 2013-11-02

*** hashmal has quit IRC00:02
*** mkroehnert has quit IRC02:08
*** gatesphere has joined #io02:24
prologichey jer u around?02:30
*** gatesphere has quit IRC03:07
prologichttps://pypi.python.org/pypi/mio-lang/0.0.606:07
*** OpenSpace has quit IRC07:58
*** mkroehnert has joined #io08:09
*** OpenSpace has joined #io08:11
*** hashmal has joined #io09:45
*** fredreichbier has joined #io11:31
*** fredreichbier has quit IRC13:14
*** gatesphere has joined #io13:47
jeryeah i'm around14:38
jerprologic, your first example should really be like this: Number fact := method((1..self) reduce(0, a, n, a * n)) =D14:40
jerbtw, in terms of your goal of implementing coroutines; you can simulate coroutines by defining a simple scheduler which maintains a queue of continuations. you add a continuation to this queue, and pop another one off when you're ready to run14:57
jerit's very naive, but gets you to a place to start =]14:57
prologicand this would avoid the recursion limit I'm having as well no doubt?15:04
jerdepends... you could implement reduce/foldl iteratively, which yes, would avoid the recursion limit you've got15:09
prologicyeah well at the moment my message evalulator can call an activateable block/method or a continatuion which in trun calls the evaluator15:11
prologicyou acn see how th C stack gets exceeded :)15:11
prologicin general couldn't I just process all messages in a queue with a running schedular?15:12
jeryou could15:12
jerthat's generally how i'd go about implementing a run loop15:12
prologic*nods*15:14
prologicI think I might do that at some stage15:14
prologicalso re your example above15:14
prologicI _could_ rewrite the example like this15:14
prologicalmost (I think)15:14
prologicI already have Range and .. syntax and a reduce builtin function15:14
prologicI'll have to see if I can :)15:14
jeroh that's another thing, i would avoid builtins in mio15:15
jerif you want to be able to call them from a python ffi, that's one thing15:16
jerbut i wouldn'tm ake them in an io directly15:16
jerinstead what i'd do, is define traits for this purpose15:16
prologicoh I am15:17
prologicbut also builtins (simple functions)15:17
jeryeah what i'ms aying is ignore the builtins, implement those as traits instead15:19
jer"builtins" don't really make sense in an io like language15:20
jerwhich has only local state objects15:20
jerio objects are basically just N-way trees15:20
jeryou start from the Lobby (though there's a duality between Object and Lobby that's not entirely representable by this idea)15:20
jerand then work your way down15:20
jerit's all local, there is no global state15:21
jerso there's no real place where a builtin can live and it 'make sense'15:21
prologichmm15:23
prologicI'm so heavily influenced by python :)15:23
prologicI like to write: print("foo")15:24
prologicinstead of "foo" print()15:24
prologicheh15:24
prologicbtw is there a straight forward way to reshuffle the message chain for operator precedence?15:24
prologiceverytime I've tried this I've failed15:25
jerwhat you can do15:30
jeris maintain a map of operator -> priority level15:30
jerand just run it against the token stream15:30
jerinsert ( and ) at the appropriate spots15:30
jerthat's what io's operator table stuff does15:30
prologichmm15:31
jerthe way you can do that is you read ahead in the token stream15:32
jerfor where to place the )15:32
jerif you come across an equal or lower priority token name, insert a )15:32
jerif you come across a token with a higher level, insert another ( and remember you need to place two )'s15:32
jerdo this over the token stream before you evaluate15:33
jerall will be will15:33
jerall will be well15:33
prologichmm I see15:34
jerthere's no reason that in a less naive approach you couldn't start evaluating when you've balanced the () level at 015:37
jeri.e., no more need to insert a )15:38
jerso you could do parsing concurrently while evaluating15:38
jeryou'd have ot maintain some kind of barrier though so the evaluation didn't overtake the parsing15:38
jeri.e., block the mutator until another chunk of the message tree is available to be evaluated15:38
jerit inserts pauses in the running program, but at least it's not a giant pause at the start15:38
jer(keep in mind, when i say giant, i'm talking about milliseconds, not seconds)15:39
jerso mutator pauses, if any inline with evaluation, shouldn't be more than a few milliseconds tops; as opposed to say 100 ms tops at the start of evaluation the naive way15:39
prologichttp://codepad.org/awPU3KmN15:51
prologicalmost there :)15:51
prologicfew bugs15:51
prologichmm15:58
prologic>>> x = parse("1 + 2 * 3 + 4")15:58
prologic>>> x15:58
prologic1 +(2 *(3 +(4)))15:58
prologicnot quite right there15:58
prologicI expect 1 +(2 *(3)) + 415:59
jeryeah so you have to keep track of all of the precedence levels you've hit; and their indexes15:59
prologicoh?16:00
prologichmm16:00
prologiccan you elaborate on what needs to happen?16:00
prologickeep a stack of levels?16:00
jeralright so, think of it like two stacks16:00
prologicand push/pop the stack?16:00
jera stack of tokens16:00
jeractually let me rephrase16:00
jera stream of tokens, and an index stack16:01
jerwhen you go to insert a ) in the token stream, you pop the index off the stack, then look ahead, and see if the next token is >= the last token's precendence level, and keep inserting ) until it's >= last precedence16:01
jererr until it's greater than; not >=16:02
prologichttp://codepad.org/sjtZQdNt16:13
prologicthis seems to work16:13
prologicam I missing anything?16:13
jertest it out the ass16:14
jerevery type of expression you can think of from simple to annoyingly complicated16:14
jerhave calls to methods in there too, malformed parse trees16:14
prologichmm no it's still wrong16:14
jerremember that giving good locations of errors is REALLY HARD in io16:15
prologictell me about it :)16:15
prologicI have basic stack traces now16:15
prologicbut they suck/ugly16:15
prologicthey're helpful but not nearly enough16:15
prologichmm16:16
prologicseems I'm not quite getting the last bit you said16:16
prologicwhen you go to insert a ) in the token stream, you pop the index off the stack, then look ahead, and see if the next token is >= the last token's precendence level, and keep inserting ) until it's > last precedence16:16
jernono sorry, all instances of >= should be >16:16
jerso given an expression like:16:17
jer1 + 2 * 4 / 2 + 7 - 1 * 416:17
jeryou'd expect that to parse like this:16:17
jer1 +(2 *(4) /(2)) +(7) -(1 *(4))16:17
jerwhen you encounter the first +16:17
jeryour level is 016:17
jerlet's say + lives at level 316:18
jerthen you have a stack of levels: 3 016:18
jerwhere 3 is at the top16:18
jerypu push a ( into the stream16:18
jerafter +16:18
jerand continue reading on16:18
jeryou peek at the top of the stack when you encounter the next token 2, it's not in the op table, so you continue, then the next token is a *16:18
jerit's in the op table at level of say 416:18
jerso you push 4 onto the stack, insert another (16:19
jerlook ahead, you see 4 which is < the top of the levels stack16:19
jerso you add a )16:19
jeryou look ahead, see / which is > the top of the stack (3) so you insert a ( after it16:19
jernext token is 2, which is level 0, and less than 316:19
jererr less than 416:19
jersince / is 416:19
jerso you pop 4 from the stack, insert a )16:19
jerthen you look ahead, see that + is euqal to 3, so you add another ) before +16:20
jerso now your level stack has one item, 016:20
prologicahh16:20
jerit could even be empty16:20
prologicI think I get it16:20
jerclearer?16:20
prologicmuch :)16:20
jerbtw, the above algorithm is not tested, and i have not proven it correct formally =]16:20
jeri would seriously write a shit ton of tests against your parser16:23
jerit's your language's user interface16:23
jerit's gotta be right16:23
jerdevelopers are more forgiving of library bugs than parser bugs16:23
*** fredreichbier has joined #io16:24
prologic*nods*16:25
jerprologic, every single way you can think of; including missing )16:25
prologicmio has over 250+ unit tests atm16:25
jeri.e., dev writes 1 + 2 * (1 + 316:25
jerah cool16:25
prologic*nods*16:25
prologicI'm not even close to rewriting in RPython yet16:25
prologicsadly :)16:25
jertbh i think that's one area io could be better at interpreting the error16:25
prologicbut it's coming along16:25
jerif we encounter a ; or newline, and there are unbalanced ()'s []'s or {}'s, then throw an error16:25
jerso long as the last token before the ; or ( was not a comma16:26
jerso it'd still allow:16:26
jerfoo := method(a, b,16:26
jer...16:26
jer)16:26
jerbut not: 1 + 2 * (1 + 316:26
jeroh and another corner case: comma or (16:26
jerfoo := method(16:26
jer...16:26
jer)16:26
jershould be legit too16:26
jerthis would give you PRECISE information about the line of the problem16:27
prologicsure16:27
prologicspeaking of syntax16:28
prologicwould there be some syntax that would make sense for passing unevaluated message blocks around?16:28
prologicreducing the need to inspect call message args16:28
jermessage(1 + 2)16:28
prologicahh perfect :)16:28
jeroh16:28
jermessage(1 + 2) just creates a Message object16:29
prologicor how about16:29
prologic|1 + 2|16:29
prologicas syntactic sugar16:29
prologicwhere16:29
jeri.e., message := method(Message clone fromString(call message arguments at(0) asString))16:29
prologic|| = Message getSlot("message")16:29
jeri don't like16:29
jeryou could define method() as syntax i guess16:29
jerinstead of itself a method16:30
jerand then in its arg list16:30
jerdo something like:16:30
jermethod(a, b, c=unevaluated, ...)16:30
jerthe method would encode the position of c as an index into the arguments list16:30
jerthus avoiding some boilerplate in your method body16:30
*** gatesphere has quit IRC16:30
jerc would be a message type inside your method16:30
prologic*nods*16:30
jeri don't like that either, but if i had to pick between || and that, i'd pick that16:31
jeri want to implement an untyped term rewriting engine16:39
jeri could most certainly use that to implement decent pattern matching for objc16:41
jerin a library16:41
*** gatesphere has joined #io18:37
*** fredreichbier has quit IRC19:25
*** fredreichbier has joined #io23:26

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