--- Log opened Tue Oct 31 00:00:06 2006 |
00:04 | | Chalcy is now known as Chalcedon |
00:06 | <@Vornicus> | The "oh crap moment": |
00:06 | <@Vornicus> | $ nano foo.sh |
00:06 | <@Vornicus> | bash: nano: command not found |
00:06 | <@Vornicus> | $ pico foo.sh |
00:06 | <@Vornicus> | bash: pico: command not found |
00:06 | <@Vornicus> | $ vi foo.sh |
00:06 | <@Vornicus> | bash: vi: command not found |
00:06 | <@Vornicus> | ...same with emacs. and ed. |
00:07 | <@Reiver> | ...Uhpoh? |
00:08 | <@Vornicus> | > X EDITOR |
00:08 | <@Vornicus> | There is no such thing here. |
00:09 | <@McMartin> | vim? |
00:09 | <@McMartin> | elvis? |
00:09 | <@McMartin> | echo $EDITOR ? |
00:10 | <@Vornicus> | vim no, elvis no, $EDITOR blank |
00:10 | <@McMartin> | cat - > out.txt |
00:11 | <@Vornicus> | ;_; |
00:11 | <@McMartin> | yum install emacs |
00:11 | <@ToxicFrog> | jove? |
00:11 | <@Vornicus> | jove no, joe no |
00:12 | <@ToxicFrog> | But, yeah, # yum install nano 4tw. |
00:12 | | * Vornicus eyes |
00:12 | <@Vornicus> | AH |
00:12 | <@ToxicFrog> | ? |
00:12 | <@Vornicus> | it is cygwin. |
00:12 | <@ToxicFrog> | ...cygwin comes with nano and vi and emacs. |
00:12 | <@ToxicFrog> | At least, mine did. |
00:12 | <@Vornicus> | Apparently mine did not. |
00:12 | <@ToxicFrog> | Then again, I always install absolutely everything. |
00:14 | <@ToxicFrog> | Partly because I use most of it, and partly because the installer isn't always correct about dependency resolution. |
00:22 | | * Vornicus ljposts on this. |
00:43 | | EvilSchemingLord [althalas@Nightstar-17046.a80-186-184-83.elisa-laajakaista.fi] has quit [Ping Timeout] |
00:54 | | EvilSchemingLord [althalas@Nightstar-17046.a80-186-184-83.elisa-laajakaista.fi] has joined #code |
01:08 | | Chalcedon is now known as ChalcyWorkPrep |
01:15 | <@ToxicFrog> | You know, more and more, I find the fact that windows lacks something like yum vexing. |
01:15 | <@ToxicFrog> | If I want my scummvm, I don't want to have to actually use a web browser to locate it. |
01:16 | <@McMartin> | scummvm.sf.net |
01:16 | <@McMartin> | yum install mtv |
01:21 | <@ToxicFrog> | mtv? |
01:22 | <@ToxicFrog> | And, yes, I know where to found it, I've already installed it and am watching the Sam & Max intro. |
01:22 | <@ToxicFrog> | It's just more irritating than just saying # yum install scummvm |
01:25 | <@ToxicFrog> | I like it more than DOTT already. |
01:29 | <@McMartin> | "Well, that was a pleasantly understated credits sequence." |
01:29 | <@McMartin> | MTV had a very obnoxious ad campaign back in the 80s along the lines of "I want my MTV" |
01:30 | <@McMartin> | The puzzles in Sam and Max weren't as good. |
01:30 | <@ToxicFrog> | Ok, I've got the ! and the ?, but what does the rubber duckie mean? |
01:30 | <@McMartin> | "Non-Sequitur" |
01:30 | <@ToxicFrog> | Oh. Sweet. |
01:31 | <@McMartin> | "Impersonate Zippy the Pinhead" |
01:31 | <@ToxicFrog> | ...and now we play, "plz to be explaining why you are running at 60Hz" |
01:31 | <@Vornicus> | hee |
01:31 | <@McMartin> | NTSC for life, yo |
01:32 | <@ToxicFrog> | I have no problems with the game running at 60fps, but I object when my monitor follows suit. |
01:33 | <@ToxicFrog> | ...aha. Because it's forgotten my RefreshForce settings. |
01:38 | <@ToxicFrog> | Hmm. I need to cause cat vomit. |
01:40 | <@ToxicFrog> | > COMBINE MAX WITH MOGGIE |
01:40 | <@ToxicFrog> | I should have thought of that way earlier. |
01:41 | | Janus [~Cerulean@Nightstar-10302.columbus.res.rr.com] has quit [Quit: Ping Timeout] |
01:42 | | Janus [~Cerulean@Nightstar-10302.columbus.res.rr.com] has joined #code |
01:43 | <@Vornicus> | |
01:43 | <@ToxicFrog> | ? |
01:45 | <@Vornicus> | This game sounds like /fun/ |
01:47 | <@ToxicFrog> | S&MHTR is, I believe, one of the games commonly listed - along with Day of the Tentacle and Monkey Island and probably some others I'm forgotting - as one of the Great Lucasarts Classics. |
01:48 | <@ToxicFrog> | Which is why it's taken me so long to get around to it. |
01:53 | | * Vornicus goes home now. |
01:53 | | Vornicus [~vorn@Nightstar-18307.slkc.qwest.net] has quit [Quit: ] |
01:58 | <@Reiver> | Idly. |
01:58 | <@Reiver> | Is writer.write(line + "\n"); the right way of writing a new line to a file? |
01:59 | <@Reiver> | Er. In Java. |
02:10 | | ChalcyWorkPrep is now known as ChalcyWork |
02:14 | | Chalcy [~Chalceon@Nightstar-869.bitstream.orcon.net.nz] has joined #code |
02:14 | | mode/#code [+o Chalcy] by ChanServ |
02:16 | | ChalcyWork [~Chalceon@Nightstar-869.bitstream.orcon.net.nz] has quit [Ping Timeout] |
02:20 | <@Reiver> | ...Abuh. |
02:20 | <@Reiver> | Ruby just took two full minutes to extract itself. |
02:20 | | * Reiver is impressed. |
02:57 | | Vornicus-Latens is now known as Vornicus |
03:02 | | Janus [~Cerulean@Nightstar-10302.columbus.res.rr.com] has quit [Quit: ~] |
03:18 | <@McMartin> | Reiver: I believe println with a PrintWriter is best |
03:18 | <@McMartin> | But \n is not automatically converted for you, no. |
03:18 | <@Reiver> | Right. |
03:18 | <@McMartin> | There's a system property -- I think it's called line.separator -- that has the right value for all OSes. |
03:19 | <@McMartin> | http://www.stanford.edu/~mcmartin/misc/melebkgd.0.png |
03:21 | <@Reiver> | Aha |
03:21 | <@Reiver> | writer.newLine(); |
03:21 | <@Reiver> | ...Pretty, McM |
03:22 | <@McMartin> | The change of note being the "Net..." buttons. |
03:22 | <@Reiver> | ...Network? |
03:23 | <@McMartin> | Indeed. The current devtree has netplay supermelee, but only configurable via command-line. |
03:24 | <@Reiver> | Oh my. |
03:57 | | ChalcyGone [~Chalceon@Nightstar-869.bitstream.orcon.net.nz] has joined #code |
03:57 | | ChalcyGone is now known as Chalcedon |
03:57 | | Chalcy [~Chalceon@Nightstar-869.bitstream.orcon.net.nz] has quit [Killed (NickServ (GHOST command used by Chalcedon))] |
05:16 | | Thaqui is now known as ThaquiWork |
05:23 | | MahalWORK is now known as Mahal |
05:48 | | Mahal is now known as MahalAFK |
06:32 | | You're now known as TheWatcher |
06:33 | | SouthernMyst [~SouthernM@Nightstar-26801.fv.dl.cox.net] has joined #code |
06:33 | | SouthernMyst [~SouthernM@Nightstar-26801.fv.dl.cox.net] has left #code ["Diplomacy is the art of saying 'Nice doggy' until you can find a rock." -- Will Rogers] |
06:50 | | Syloqs-AFH [Syloq@Admin.Nightstar.Net] has quit [Connection reset by peer] |
07:45 | | Chalcedon [~Chalceon@Nightstar-869.bitstream.orcon.net.nz] has quit [Ping Timeout] |
08:27 | | Vornicus is now known as Vornicus-Latens |
08:54 | | Chalcedon [~Chalceon@Nightstar-869.bitstream.orcon.net.nz] has joined #code |
08:54 | | mode/#code [+o Chalcedon] by ChanServ |
08:58 | | Chalcedon is now known as ChalcyZzz |
09:05 | | Chalcy [~Chalceon@Nightstar-869.bitstream.orcon.net.nz] has joined #code |
09:05 | | mode/#code [+o Chalcy] by ChanServ |
09:06 | | ChalcyZzz [~Chalceon@Nightstar-869.bitstream.orcon.net.nz] has quit [Ping Timeout] |
09:41 | | You're now known as TheWatcher[wr0k] |
10:04 | | EvilSchemingLord is now known as EvilNromLord |
10:17 | | ThaquiWork is now known as Thaqui |
11:11 | | Reiv [~reaverta@IRCop.Nightstar.Net] has joined #Code |
11:11 | | Reiver [~reaverta@IRCop.Nightstar.Net] has quit [Ping Timeout] |
11:12 | | Reiv is now known as Reiver |
11:44 | | EvilNromLord is now known as EvilDarkLord |
12:15 | | Thaqui [~Thaqui@Nightstar-8486.adsl.xtra.co.nz] has quit [Ping Timeout] |
12:21 | | Chalcy [~Chalceon@Nightstar-869.bitstream.orcon.net.nz] has quit [Ping Timeout] |
12:36 | | Thaqui [~Thaqui@Nightstar-26630.broadband-telecom.global-gateway.net.nz] has joined #code |
12:45 | | Reiver is now known as ReivZzz |
12:45 | | Thaqui is now known as ThaquiSleep |
13:19 | | EvilDarkLord [althalas@Nightstar-17046.a80-186-184-83.elisa-laajakaista.fi] has quit [Ping Timeout] |
14:31 | | Netsplit DeepThought.NY.US.Nightstar.Net <-> Troika.TX.US.Nightstar.Net quits: @Pi, Raif, Vornicus-Latens, ReivZzz, @jerith, @Chalain |
14:31 | | Netsplit over, joins: Raif |
14:31 | | mode/#code [+o Raif] by ChanServ |
14:32 | | Netsplit over, joins: Chalain, Vornicus-Latens, jerith |
14:32 | | mode/#code [+o Chalain] by ChanServ |
14:32 | | Netsplit over, joins: ReivZzz |
14:32 | | mode/#code [+o jerith] by ChanServ |
14:32 | | jerith [~jerith@IRCop.Nightstar.Net] has quit [Ping Timeout] |
14:32 | | jerith [~jerith@IRCop.Nightstar.Net] has joined #code |
14:32 | | mode/#code [+o jerith] by ChanServ |
14:41 | | EvilDarkLord [althalas@Nightstar-17046.a80-186-184-83.elisa-laajakaista.fi] has joined #code |
15:21 | <@ToxicFrog> | AhahahahahaHAHAHAHAHAHAHAHAHAHAHAHA |
15:22 | < EvilDarkLord> | Your views are enlightening and I wish to subscribe to your newsletter. |
15:33 | | * TheWatcher[wr0k] eyes TF |
15:33 | <@TheWatcher[wr0k]> | SRMD meds run out? |
15:34 | <@ToxicFrog> | Oh, those ran out last august~ |
15:34 | <@ToxicFrog> | But now I have wireless - including WPA - working under FC5. |
15:42 | | Safyra [Safyra@Nightstar-4370.ok.ok.cox.net] has joined #code |
15:43 | | Safyra is now known as Stephenie |
15:43 | | * ToxicFrog waves |
15:44 | | * Stephenie waves at frog |
16:03 | | * ToxicFrog fiddles with blcgen, which he should probably release a final version of one of these days |
16:28 | | Pi [~sysop@Nightstar-6915.hsd1.or.comcast.net] has joined #Code |
16:28 | | mode/#code [+o Pi] by ChanServ |
16:43 | | You're now known as TheWatcher |
17:38 | | * jerith wanders in. |
18:02 | <@jerith> | SYN |
18:06 | <@Raif> | ACK |
18:06 | <@jerith> | Ah, there is someone else awake in here. :-) |
18:07 | <@Raif> | Sorry for the latency... apparently you've already timed out. |
18:07 | <@jerith> | Aren't you supposed to reply with a SYN/ACK? |
18:08 | <@Raif> | +++ Out of cheese error: Redo from start +++ |
18:15 | <@ToxicFrog> | +++ Please reinstall universe and reboot +++ |
18:37 | | MahalAFK is now known as Mahal |
19:18 | | Mahal is now known as MahalEarn |
19:31 | | * jerith ponders block scoping rules in Ruby. |
19:43 | <@ToxicFrog> | What about them? |
19:43 | <@jerith> | They're horrible. |
19:44 | <@ToxicFrog> | Oh. |
19:44 | <@ToxicFrog> | How so? |
19:44 | <@jerith> | foo.each { |foo| dosomething(foo) } |
19:44 | <@ToxicFrog> | I mean, they're block scoping rules. |
19:44 | <@jerith> | Breaks foo. |
19:44 | <@ToxicFrog> | Surely you can't break those too much. |
19:44 | <@jerith> | Why should a *parameter* stomp on an external variable. |
19:44 | <@ToxicFrog> | (well, unless you're MS writing a C compiler~) |
19:45 | <@ToxicFrog> | ...because a parameter is, in effect, a local variable? |
19:45 | <@ToxicFrog> | What's the actual problem here? |
19:45 | <@ToxicFrog> | It breaks foo /outside/ the {}? |
19:45 | | * jerith nods. |
19:46 | <@ToxicFrog> | ... |
19:46 | <@ToxicFrog> | This is a problem I had previously thought unique to the MS C compiler, and various languages where everything is a global. |
19:46 | <@jerith> | Hmm, it seems to work there. |
19:47 | <@jerith> | It broke on my XML stuff, though. |
19:47 | <@ToxicFrog> | "there"? |
19:47 | <@jerith> | Perhaps I'm mistaken. |
19:47 | <@jerith> | I just tried it in irb. |
20:53 | | Chalcedon [~Chalceon@Nightstar-869.bitstream.orcon.net.nz] has joined #code |
20:53 | | mode/#code [+o Chalcedon] by ChanServ |
20:54 | | Chalcedon is now known as ChalcySick |
21:46 | | Chalain [~chalain@Admin.Nightstar.Net] has quit [Quit: leaving] |
21:54 | | Chalain [~chalain@Admin.Nightstar.Net] has joined #code |
21:54 | | mode/#code [+o Chalain] by ChanServ |
22:04 | <@Chalain> | jerith: I believe the Ruby thing is due to the fact that when you call each {}, it's not a block in the sense of a scope, but rather a block in the sense of a closure that carries with it the outer environment. |
22:05 | <@Chalain> | each() is a function call that receives a block. |
22:05 | | Janus [~Cerulean@Nightstar-10302.columbus.res.rr.com] has joined #code |
22:06 | <@Chalain> | It yields into the block the currently iterated value and allows the outer environment to be accessible. |
22:06 | <@Chalain> | If you assign to the outer environment, the assignment holds. |
22:07 | <@Chalain> | For example: |
22:07 | <@Chalain> | irb(main):021:0> q = [3,2,1] |
22:07 | <@Chalain> | => [3, 2, 1] |
22:07 | <@Chalain> | irb(main):022:0> q.each {|x| print "Yo"; q=4} |
22:07 | <@Chalain> | YoYoYo=> [3, 2, 1] |
22:07 | <@Chalain> | irb(main):023:0> q |
22:07 | <@Chalain> | => 4 |
22:08 | <@Chalain> | If I query the value of x, it *might* actually contain the value 1. |
22:09 | <@Chalain> | But ONLY if I defined x before the loop. |
22:09 | <@Chalain> | Otherwise it's a local variable and passes away. |
22:09 | <@Chalain> | So yeah, if you're expected C-style scoping, you'll get bit. It's a lisplike closure. :-) |
22:10 | <@Chalain> | ...and your comment has seriously given me food for thought, because while I understood that foo.each {|foo| ...} was a Bad Idea, I had forgotten that x=4 will assign to the outer x. |
22:11 | <@ToxicFrog> | ...I don't know about lisp, but closures in Lua definitely don't behave like that. |
22:11 | <@Chalain> | ToxicFrog: Well, this is a special case. The key thing here is that each() is a closure block, not a scoping block. |
22:12 | <@Chalain> | And as near as I can tell, Lua's closures do work that way (but not Lua's block scope) |
22:12 | < Vornicus-Latens> | C-style scoping only really exists in languages where you declare the variable before you use it. like C and Java |
22:12 | <@ToxicFrog> | Well, they can't work that way, because in Lua, lexical scope == variable scope == closure scope. |
22:12 | <@Chalain> | ...at least in the sense that you can create a closure that can access the external environment--OH, I see what you mean. It may not be able to assign BACK to that outer environment. |
22:12 | <@Chalain> | I'll need to test that. |
22:12 | <@ToxicFrog> | If I'm understanding this correctly. |
22:13 | <@ToxicFrog> | Lua can definitely assign to the outer environment from inside a closure. |
22:13 | <@ToxicFrog> | However, it is also possible to declare variables local to the closure. |
22:13 | <@ToxicFrog> | So that you can assign to them /without/ trashing the global environment. |
22:13 | <@McMartin> | Lisp can too (setq, etc.), but you very rarely actually set things in Lisp, so. |
22:14 | <@Chalain> | ToxicFrog: One thing I do know you can do is to create a closure that uses an environment var. If you then assign overtop of that var outside the closure, the closure does not see the new assignment; I believe this is the case in Ruby as well. I don't know what happens the other direction, though. Hmmm! Food for thought. |
22:14 | < Vornicus-Latens> | woo functional programming |
22:14 | <@ToxicFrog> | Chalain: what do you mean by an "environment var"? |
22:15 | <@Chalain> | Vornicus-Latens: Python *sort* of has lexical == variable scope, but it has some gotchas in it (and keywords to explicitly work around them). |
22:15 | <@Chalain> | ToxicFrog: Sorry, I've been doing a lot of scheme studying lately. |
22:15 | <@McMartin> | Assigning to intermediate-scope locals is painful like whoa just conceptually. |
22:15 | <@ToxicFrog> | I do know that if you create a closure that refers to a global, and then call it, it gets the value of the global when it was called. |
22:15 | <@ToxicFrog> | Not the value of the global when it was created. |
22:16 | <@McMartin> | Actually, in 15 minutes the guy who invented Common LISP, and also much of Scheme and Java, is giving a talk on some parallel language he's been working on. |
22:17 | | * McMartin heads off to that, will report back. |
22:17 | <@ToxicFrog> | Similarly, if you create a closure that refers to a local, and call it, it gets the value that local had when it was last in scope (ie, at the end of the block where this closure was declared or at the end of the last time this closure or another one referencing it was called), not the value it had when the closure was declared. |
22:17 | < Vornicus-Latens> | Chalain: in the sense of, "yeah, that variable you declared in the if branch there? the rest of the function can't see that" |
22:17 | <@ToxicFrog> | So I'm not sure what you're talking about. |
22:17 | < Vornicus-Latens> | which has bit me. |
22:18 | <@Chalain> | ToxicFrog: ...You've just described my understanding of the environment a closure receives--it is the list of known-to-exist (references to) variables at the time of the method's creation. |
22:18 | <@ToxicFrog> | Yes. References. Not values. |
22:18 | <@ToxicFrog> | You were saying values earlier earlier. |
22:19 | < Vornicus-Latens> | speaking of lisp, I need to grab the next sicp lecture |
22:19 | <@Chalain> | I'm calling exactly that thing "the environment". If I have said something different, point it out and I'll see where I went wrong.:-) |
22:19 | <@Chalain> | Oh |
22:19 | <@ToxicFrog> | "One thing I do know you can do is to create a closure that uses an environment var. If you then assign overtop of that var outside the closure, the closure does not see the new assignment" |
22:19 | <@ToxicFrog> | This is not the case. |
22:19 | <@ToxicFrog> | The closure gets a reference to that variable, so if you assign to it and then call the closure, it sees the new value. |
22:19 | <@ToxicFrog> | At least, in Lua. |
22:19 | | * Chalain squints at that. Hmmm. |
22:20 | <@McMartin> | TF: What happens when you write to it, though? |
22:20 | <@McMartin> | Does it write to the upvalue, or create a new local? |
22:20 | <@Chalain> | This will inspire some testing. See, now I wonder if the variables are stored, or if the references are stored. |
22:20 | <@ToxicFrog> | Oh, from inside the closure? |
22:20 | <@McMartin> | Yeah |
22:20 | <@ToxicFrog> | It writes to the upvalue. |
22:20 | <@Chalain> | Because if it's just references, then Lua shouldn't see globals get updated. |
22:21 | <@ToxicFrog> | Chalain: references to the variables are stored. |
22:21 | <@ToxicFrog> | Or whatever the VM uses internally. |
22:21 | <@McMartin> | ... yeah, closures link to the environment frames, they don't do value copies. |
22:21 | | * McMartin hasn't gotten around to implementing Pocket in JS. |
22:21 | <@ToxicFrog> | The point is, when creating a closure, all upvalues are stored by reference, even those that are normally passed by value like numbers. |
22:22 | <@ToxicFrog> | As for writing to upvalues - yes, Lua writes to the actual upvalue rather than creating a new local shadowing it. |
22:22 | <@Chalain> | foo = x -- stores reference to x in foo. So, does the closure get foo or &x? Because if you reassign foo to y, foo now contains &y, but the closure should still have &x. |
22:22 | <@Chalain> | ...unless the closure has... AHH! I see it. |
22:22 | <@Chalain> | The closure hase &foo. |
22:22 | <@McMartin> | Chalain: ... you're mixing levels. I don't have time to explain... oh good. |
22:22 | <@ToxicFrog> | Yes. |
22:22 | <@ToxicFrog> | Exactly. |
22:22 | <@Chalain> | If you assign a new global value, &foo points to the new value. |
22:22 | <@ToxicFrog> | Anyways! Ruby. As I understand it, the issue you're seeing here is that arguments to a closure are not implicitly local. |
22:23 | <@ToxicFrog> | And thus whack whatever was upscope of the closure. |
22:23 | <@Chalain> | If you create a new local, it will create a new object, &foo', which has a different address than foo. |
22:23 | <@ToxicFrog> | Whereas in lua, arguments are implicitly local and thus shadow, but do not overwrite. |
22:23 | <@ToxicFrog> | Exactly. |
22:23 | <@ToxicFrog> | If foo is an upvalue, then: |
22:23 | <@ToxicFrog> | foo = x; -- foo now has value x in whatever scope foo lives in |
22:23 | <@Chalain> | Okay, then yes. This would produce the behavior that locals become private to the closure while globals remain mutable. Neet! |
22:24 | <@Chalain> | So, /me goes back and looks at that Ruby code. |
22:24 | <@ToxicFrog> | local foo = x; -- creates a new foo that shadows the upvalue |
22:24 | <@ToxicFrog> | And all arguments are, as stated earlier, implicitly local. |
22:24 | <@ToxicFrog> | So you don't end up with environment overwrite whackiness as shown above. |
22:24 | <@Chalain> | Yeah, it makes sense. Having found assignment to variable foo, jerith's code writes to global (visible outside the closure and not passed in) variable foo. |
22:25 | <@ToxicFrog> | Despite the fact that foo is /also/ an argument to the closure? |
22:25 | <@Chalain> | Ooooh, but the |x| *REALLY* looks like a variable passed in. But yeah, it's not--it's the reference to the yielded param. Wow. |
22:25 | <@ToxicFrog> | Augh. |
22:25 | <@ToxicFrog> | So it's not really an argument. |
22:25 | <@Chalain> | Well, the key thing is that (x) and |x| are behaving differently, and I think you, jerith, and I want them to behave the same--e.g. bound locals. |
22:25 | <@ToxicFrog> | It's something else. |
22:26 | <@Chalain> | right |
22:26 | <@ToxicFrog> | And using { (x) ... } instead of { |x| ... } would create a new local shadowing the upvalue? |
22:27 | <@Chalain> | This makes me wonder then if |x| is just syntactic sugar for something like yield(*args) { x = args[0]; ... } |
22:27 | <@ToxicFrog> | Probably. |
22:27 | <@ToxicFrog> | What does yield do in Ruby, anyways? |
22:27 | <@ToxicFrog> | In Lua it's a coroutine context switch with returns. |
22:27 | <@Chalain> | I think it would shadow the upvalue but it wouldn't receive the iterated value. |
22:28 | <@Chalain> | That sounds about right, but I do not know the precise definition. |
22:28 | | You're now known as TheWatcher[afk] |
22:28 | <@ToxicFrog> | .../what/ would shadow the upvalue? |
22:28 | <@Chalain> | Consider this code: foo.each {|x| puts x} |
22:29 | <@ToxicFrog> | Right. |
22:29 | < Vornicus-Latens> | irb(main):003:0> foo.each{|foo| puts foo} |
22:29 | < Vornicus-Latens> | 1 |
22:29 | < Vornicus-Latens> | 2 |
22:29 | < Vornicus-Latens> | 3 |
22:29 | <@Chalain> | each() is a method that receives a block. So somewhere in class Enumerable we have something akin to: def each(self, &block); for(i=0; i<self.length; i=i+1) { yield self[i] } end |
22:30 | <@ToxicFrog> | Right, but what I'm asking is, what does yield do? |
22:30 | <@Chalain> | Yield calls into the block supplied to the method. Any arguments passed in are fitted to the |varlist| |
22:30 | <@ToxicFrog> | Aah. |
22:30 | <@ToxicFrog> | ...and in the above code yield implicitly recieves block as an argument? |
22:30 | <@ToxicFrog> | Or a prepend, or something? |
22:30 | <@Chalain> | Yes. |
22:30 | <@ToxicFrog> | ... |
22:31 | <@Chalain> | yield x essentially becomes block.send(:call, x) |
22:31 | <@Chalain> | meh, block.call(x) |
22:31 | <@ToxicFrog> | Ok. That kind of implicit argument passing gives me the jibblies, but ok. |
22:32 | <@Chalain> | Well, it's not entirely implicit. |
22:32 | <@ToxicFrog> | Oh? |
22:32 | <@Chalain> | def each() *must* declare that it receives a block, and the |varlist| is checked for numericity and will throw IllegalArgumentException if nPassed != nExpected. |
22:33 | <@ToxicFrog> | No. I mean implicitly passing the block to yield. |
22:33 | <@ToxicFrog> | What happens if you call yield from outside each? Does it just randomly grab something called "block" from the current scope? Does it raise an error? |
22:34 | <@Chalain> | Oh. Well, like I said, yield x is essentiall syntactic sugar for block.call(x) |
22:34 | <@Chalain> | No. Block must be declared in the bound variable list. |
22:34 | <@Chalain> | (and you can only have one.) |
22:34 | <@ToxicFrog> | Ok. |
22:34 | <@ToxicFrog> | So it's really more like a macro and not syntactic sugar as I generally think of it. |
22:34 | < Vornicus-Latens> | except that it doesn't actually have a name |
22:34 | < Vornicus-Latens> | usually |
22:36 | | * Chalain gurks. |
22:37 | < Vornicus-Latens> | the block doesn't, that is |
22:37 | <@Chalain> | So, um. When I said you have to declare the block explicitly? Not entirely, as it were, true. |
22:37 | <@ToxicFrog> | ... |
22:37 | | * ToxicFrog burbles |
22:37 | <@ToxicFrog> | See, this is why I don't use Ruby~ |
22:38 | <@Chalain> | Ah, you'll get a LocalJumpError: no block given if you don't send a block. |
22:39 | <@Chalain> | Ah, okay. And if you don't declare the block, you cannot do anything with it EXCEPT yield into it. |
22:39 | <@Chalain> | You can't pass it to a child function, for example. |
22:39 | <@ToxicFrog> | Aha. |
22:39 | <@ToxicFrog> | What's the distinction between blocks and functions? |
22:40 | < Vornicus-Latens> | There isn't much of one |
22:40 | <@Chalain> | Very little, if any. |
22:40 | <@ToxicFrog> | Aah. |
22:41 | <@Chalain> | Oh, I see a key difference, but it essentially has to do with being able to heft them around. |
22:41 | <@ToxicFrog> | ...Ruby functions aren't first-class? |
22:42 | <@Chalain> | In Python, if I say "def foo(x): return x*2" I can then pass foo to another method as a function pointer. |
22:42 | <@Chalain> | "def bar(f): print f(42)" would print 84. |
22:42 | <@Chalain> | But in Ruby, parentheses are not required. "foo" evaluates to foo(). |
22:42 | <@Chalain> | correction, bar(f) would print 84 if I called bar(foo). |
22:43 | < Vornicus-Latens> | barf |
22:43 | <@Chalain> | But in Ruby, bar(foo) crashes: foo expected an argument. |
22:44 | <@ToxicFrog> | Blargh. |
22:44 | < Vornicus-Latens> | usually in Ruby you throw around /symbols/ instead of methods, which is vaguely a pain, but |
22:45 | <@Chalain> | Yeah. I can't remember how to find foo in the global variables table, but on an object it's trivial. bar.send(:foo, 42) ==> bar.foo(42) |
22:45 | < Vornicus-Latens> | it makes it so if an object overrides a particular method (by singletonning, or subclassing, or just by being a different class), you get /that/ object's method named foo |
22:46 | <@ToxicFrog> | In lua, everything's an associative array, so bar.foo(42) is identical to bar["foo"](42) |
22:46 | <@ToxicFrog> | Which is handy. |
22:54 | < Janus> | While there's a small lull, may I ask a small question please...? |
23:00 | < Janus> | Mm... is there any program which would allow one to capture video, and create a small movie thing..? |
23:00 | <@ToxicFrog> | Several. |
23:00 | <@ToxicFrog> | Where do you want to capture the video from? |
23:00 | <@ToxicFrog> | Video capture card? Video file? |
23:00 | < Vornicus-Latens> | screenshot-like? |
--- Log closed Tue Oct 31 23:00:53 2006 |
--- Log opened Tue Oct 31 23:00:58 2006 |
23:00 | | TheWatcher[afk] [~chris@Nightstar-29731.dsl.in-addr.zen.co.uk] has joined #code |
23:00 | | Irssi: #code: Total of 17 nicks [4 ops, 0 halfops, 0 voices, 13 normal] |
23:01 | < Janus> | Memory I suppose... if that's what recording what goes on in a program window is. |
23:01 | | Irssi: Join to #code was synced in 26 secs |
23:02 | < ToxicFrog> | ...so you want to capture video from another program? |
23:02 | < Janus> | Aya, that's it! |
23:02 | < ToxicFrog> | Like, as Vorn said, a screenshot, only it's a video instead of a still image? |
23:02 | < ToxicFrog> | Ok. We are making progress! |
23:02 | | * Vornicus-Latens imagines he has his game, and he wants to make a movie of it. |
23:02 | | You're now known as TheWatcher |
23:02 | < ToxicFrog> | Fraps will do that, I believe. |
23:02 | < ToxicFrog> | Personally, I do it by hooking my video card into my video capture card and running amcap in the background to record. |
23:03 | < ToxicFrog> | But you may not have a video capture card. |
23:03 | < Janus> | However... I'd also want to take that footage, and make a trailer from it. (actually thought about having it save a .bmp every frame, the humanity.) |
23:04 | < Vornicus-Latens> | yeah, that's what fraps will do for you. |
23:04 | < ToxicFrog> | So, you need both video capture software, and video editing software. |
23:04 | < Vornicus-Latens> | ah |
23:04 | < ToxicFrog> | These are seperate problems, and I cannot really help you with the latter. |
23:05 | < Janus> | Alright. (when on earth did I download fraps..?) |
23:22 | | ReivZzz is now known as Reiver |
23:36 | | You're now known as TheWatcher[T-2] |
23:44 | | You're now known as TheWatcher[zZzZ] |
23:46 | < McMartin> | ... I appear to have just agreed to give a talk on Inform 7. |
23:47 | < McMartin> | (In other news, the talk was cool, and I may have to rethink my theory of multiple inheritance as a result of it) |
23:50 | < McMartin> | The interesting idea being that you only get to inherit from classes with no fields. |
23:50 | < ToxicFrog> | Oh? |
23:50 | < McMartin> | In effect, instead of mixins being an abomination, mixins are all you get. |
23:51 | < ToxicFrog> | ...how does that work? |
23:51 | < McMartin> | In Java terms, any class with fields in it is final. |
23:51 | < ToxicFrog> | Do fields include functions? |
23:52 | < McMartin> | No, fields are data values. |
23:52 | < ToxicFrog> | Ok. |
23:52 | < McMartin> | properties that are functions are methods. |
23:52 | < McMartin> | Otherwise, yeah, inherit from {} all you want. |
23:52 | < ToxicFrog> | In that case I can see it working. |
23:52 | < McMartin> | You need higher-order functions, I believe. |
23:52 | < ToxicFrog> | "Prove the following grammar is ambiguous" - I seem to recall doing this in Compilers last year~ |
23:53 | < McMartin> | "change the will to power of Joan of Arc to 2" |
23:53 | < ToxicFrog> | Not quite that complex. |
23:53 | < Reiver> | ... |
23:53 | < ToxicFrog> | S -> A |
23:54 | < ToxicFrog> | A -> A * A | I |
23:54 | < ToxicFrog> | I -> a | b | c |
23:54 | < ToxicFrog> | Too easy. |
23:56 | < ToxicFrog> | However, "Write a CFG over the alphabet { 0, 1 } that describes the language of all strings that contain more 0s than 1s" is still kicking my ass. |
23:57 | < ToxicFrog> | I may see a way, but it's kind of ugly. |
--- Log closed Wed Nov 01 00:00:53 2006 |