code logs -> 2012 -> Wed, 22 Feb 2012< code.20120221.log - code.20120223.log >
--- Log opened Wed Feb 22 00:00:41 2012
00:21
<@TheWatcher>
00:21 * TheWatcher eyes that
00:22
<@TheWatcher>
Yes.
00:23
< Namegduf>
splendid;
00:33 * TheWatcher ponders sending that to acstaff in work
00:43 You're now known as TheWatcher[T-2]
00:47 You're now known as TheWatcher[zZzZ]
00:50
<&McMartin>
actually_i_do_mind (Exception &e)
00:56 Derakon[AFK] is now known as Derakon
02:02 RichyB [MyCatVerbs@Nightstar-86656b6c.cable.virginmedia.com] has quit [Ping timeout: 121 seconds]
02:13 himi [fow035@Nightstar-5d05bada.internode.on.net] has quit [Ping timeout: 121 seconds]
02:34 himi [fow035@Nightstar-5d05bada.internode.on.net] has joined #code
02:34 mode/#code [+o himi] by ChanServ
02:45 Attilla [Obsolete@Nightstar-36422e6e.as43234.net] has quit [Ping timeout: 121 seconds]
02:47 Serah [Z@Nightstar-3602cf5a.cust.comxnet.dk] has quit [Ping timeout: 121 seconds]
03:00 Kindamoody[zZz] is now known as Kindamoody
03:29
<&Derakon>
Blah, I find myself wanting a game that is basically Devil May Cry crossed with Legend of Zelda 1.
03:30
<&McMartin>
So, Zelda 2, modernized?~
03:30
<&Derakon>
Top-down 2D melee-oriented combat with launching and rolls and so on..
03:30
<&Derakon>
No, because top-down.
03:31
<&Derakon>
One of these days I should probably figure out proper 3D OpenGL.
03:31
<&Derakon>
And semi-low-poly modeling.
03:44
<~Vornicus>
I need to get this random mission design shit out of my head
03:46 * McMartin was very happy with the models ASCII made for him for Sable
03:46
<&McMartin>
Although my Descent-1-y actually-drawn-on-graph-paper models were more fun than they should have been.
03:47
<&Derakon>
Yeah, I'd need actually animated things if I wanted to do proper melee combat.
03:47
<&Derakon>
Like, more than just spinning.
03:56 himi [fow035@Nightstar-5d05bada.internode.on.net] has quit [Ping timeout: 121 seconds]
03:59
<&Derakon>
It occurs to me that aside from the platforming segments, there's not a whole lot of depth information needed in DMC1.
04:00
<&McMartin>
This does seem to be largely true, though that style of combat is well-served by an angled if not truly isometric viewpoint
04:00
<&McMartin>
See also: Crusader: No Remorse
04:00
<&Derakon>
Which I've also not played, but yeah.
04:01
<&Derakon>
"Top down" doesn't necessarily mean 90? perpendicular.
04:02
<&McMartin>
http://i39.tinypic.com/v4qv4j.jpg
04:03
<&Derakon>
The main thing about not needing true 3D is that it simplifies the physics immensely.
04:03
<&Derakon>
Also you can get away with simpler camera controls.
04:03 * McMartin nods
04:03
<&McMartin>
CNR has agruably too-primitive camera
04:03
<&McMartin>
It's entirely fixed, and it doesn't smooth-scroll
04:03
<&McMartin>
It's snap-scrolled isometric
04:03
<&Derakon>
Well, it's not true 3D
04:03
<&Derakon>
Oh, snap-scrolling.
04:04
<~Vornicus>
ew, snap-scroll
04:05
<~Vornicus>
Many a good game was ruined on the C64 by snap-scrolling.
04:05
<&McMartin>
Machines in 1995 couldn't actually smooth-scroll Crusader graphics acceptably.
04:05
<~Vornicus>
Not that they could do much else, but it makes them Really Hard To Play.
04:06
<&Derakon>
MSX Gradius looks really weird, for example.
04:06
<&McMartin>
CNR at least was Pretty Good about snap scrolling being Not Stupid
04:06
<&McMartin>
The MSX was awful because IIRC the damn thing didn't even have proper *sprites*
04:08
<~Vornicus>
Not Stupid in what sense/
04:10
<~Vornicus>
(even worse than snap-scrolling though was the crazy stuff where you had individual screens and physics worked across them. I'm looking at you, Spindizzy)
04:10 * Derakon watches a YouTube video of Gradius 2 on the MSX, amuseds at a commenter saying "You can tell Konami didn't use their best teams on this one because they misspelled "missile" as "missilie"."
04:11
<&McMartin>
Vorn: You were very rarely engaged by enemies you couldn't see, and if you were, systematically giving that direction a lead tattoo will have you covered.
04:12
<&Derakon>
So in other words they designed their game world with the technical limitations in mind.
04:12
<~Vornicus>
Which is smart.
04:12
<&McMartin>
Pretty much
04:13
<&McMartin>
I don't recall ever being caught by an invisible camera.
04:35 himi [fow035@Nightstar-5d05bada.internode.on.net] has joined #code
04:35 mode/#code [+o himi] by ChanServ
05:13 PinkFreud [WhyNot@NetworkAdministrator.Nightstar.Net] has quit [Ping timeout: 121 seconds]
05:25 celticminstrel [celticminst@Nightstar-5d22ab1d.cable.rogers.com] has quit [[NS] Quit: And lo! The computer falls into a deep sleep, to awake again some other day!]
06:06 PinkFreud [WhyNot@NetworkAdministrator.Nightstar.Net] has joined #code
06:06 mode/#code [+o PinkFreud] by ChanServ
06:07 eckse [eckse@Nightstar-086443b9.dsl.sentex.ca] has quit [Connection reset by peer]
06:19
< Rhamphoryncus>
So, quiz time: my math was out by a factor of ~3.636. Can anybody guess what the problem was? :)
06:19
< Rhamphoryncus>
Hint: this was a calculation of speed
06:25
<@jerith>
m/s vs km/h?
06:25 * jerith has done that.
06:28
<~Vornicus>
I personally go english - metric - english to go from mi/h to ft/s
06:29 Vash [Vash@Nightstar-cdeba41f.wlfrct.sbcglobal.net] has quit [[NS] Quit: I lovecraft Vorn!]
06:44 Derakon is now known as Derakon[AFK]
06:51
< Rhamphoryncus>
jerith: divided by 60 when I should have multiplied
06:51
< Rhamphoryncus>
plus an extra factor of 1000
06:51
< Rhamphoryncus>
I'm converting rpm into km/h and 3.636 was a gear ratio
06:53 Rhamphoryncus [rhamph@Nightstar-5697f7e2.abhsia.telus.net] has quit [Client exited]
07:00 Syloqs-AFH [Syloq@NetworkAdministrator.Nightstar.Net] has quit [Client closed the connection]
07:20 Kindamoody is now known as Kindamoody|out
08:04 RichyB [MyCatVerbs@Nightstar-86656b6c.cable.virginmedia.com] has joined #code
08:22 RichyB [MyCatVerbs@Nightstar-86656b6c.cable.virginmedia.com] has quit [Ping timeout: 121 seconds]
08:24 You're now known as TheWatcher
09:01 Attilla [Obsolete@Nightstar-36422e6e.as43234.net] has joined #code
10:04 Reiver [orthianz@3CF3A5.E1CD01.C6689C.33956A] has quit [Ping timeout: 121 seconds]
10:05 RichyB [MyCatVerbs@Nightstar-3b2c2db2.bethere.co.uk] has joined #code
10:16 * TheWatcher eyes php, tries to work out the equivalent of %matchash = $foo =~ /^(\w+)\s*=\s*(.*)$/gm;
10:23
<@TheWatcher>
As far as I can tell, you can't do it - needs a preg_match_all to capture the fields in a flat array, and then walk the array converting it to a hash. Blegh
10:39
<@jerith>
Yay PHP.
11:29 * TheWatcher also stabs mediawiki in the head for apparently making it impossible to add javascript to the <head>
11:30 Stalker [Z@Nightstar-3602cf5a.cust.comxnet.dk] has joined #code
11:39
<@TheWatcher>
Oh, wait, it might be possible through arcane incantations with the resource loader. wonderful.
12:24 Reiver [orthianz@3CF3A5.E1CD01.C6689C.33956A] has joined #code
13:12 Eri [Eri@Nightstar-3e5deec3.gv.shawcable.net] has quit [Ping timeout: 121 seconds]
13:14 * TheWatcher eyes
13:15
<@TheWatcher>
Why does this work fine if I turn $wgResourceLoaderDebug on, but not if I turn it off. WTF
13:17
<@TheWatcher>
Oh, that's why, it looks like resourceloader's minifier is breaking it. Lovely.
13:25 Eri [Eri@Nightstar-3e5deec3.gv.shawcable.net] has joined #code
13:29
<@rstamer>
TheWatcher: preg_match_callback might be cleaner
13:38 maoranma [NSwebIRC@3A2961.FFEA63.0EACAC.F4C109] has joined #code
13:38
< maoranma>
werpderp
13:42
< maoranma>
God help me, I discovered DiscworldMUD
13:43 celticminstrel [celticminst@Nightstar-5d22ab1d.cable.rogers.com] has joined #code
13:43 Eri [Eri@Nightstar-3e5deec3.gv.shawcable.net] has quit [Ping timeout: 121 seconds]
13:47
<@jerith>
maoranma: I tried it, and it didn't grab me.
13:48
< maoranma>
It actually pretty neat. The skill system is really weird though
13:49
< maoranma>
afk class
13:53 maoranma [NSwebIRC@3A2961.FFEA63.0EACAC.F4C109] has quit [Ping timeout: 121 seconds]
13:57 Eri [Eri@Nightstar-3e5deec3.gv.shawcable.net] has joined #code
14:01 maoranma [NSwebIRC@D82662.C541A8.D65203.7C054A] has joined #code
15:07 Syloqs_AFH [Syloq@NetworkAdministrator.Nightstar.Net] has joined #code
15:07 mode/#code [+o Syloqs_AFH] by ChanServ
15:08 Syloqs_AFH is now known as Syloqs-AFH
15:30 Stalker [Z@Nightstar-3602cf5a.cust.comxnet.dk] has quit [[NS] Quit: ]
15:36 maoranma [NSwebIRC@D82662.C541A8.D65203.7C054A] has quit [[NS] Quit: Page closed]
15:40 Vash [Vash@Nightstar-cdeba41f.wlfrct.sbcglobal.net] has joined #code
15:40 mode/#code [+o Vash] by ChanServ
16:37 Kindamoody|out is now known as Kindamoody
16:40 Syloqs-AFH [Syloq@NetworkAdministrator.Nightstar.Net] has quit [Connection reset by peer]
16:45 Syloqs_AFH [Syloq@NetworkAdministrator.Nightstar.Net] has joined #code
16:45 mode/#code [+o Syloqs_AFH] by ChanServ
16:46 Syloqs_AFH is now known as Syloqs-AFH
17:30 * celticminstrel wonders how easy it would be to translate numpy code to Maple code.
17:31 * Tamber pours syrup into it.
17:31
<@jerith>
Some stuff would probably be easy. Other stuff would probably be hard.
17:35
< celticminstrel>
...of course. Bah.
17:37 Rhamphoryncus [rhamph@Nightstar-5697f7e2.abhsia.telus.net] has joined #code
18:12 Attilla [Obsolete@Nightstar-36422e6e.as43234.net] has quit [Client closed the connection]
18:13 Attilla [Obsolete@Nightstar-36422e6e.as43234.net] has joined #code
18:33 Attilla [Obsolete@Nightstar-36422e6e.as43234.net] has quit [Client closed the connection]
18:34 Attilla [Obsolete@Nightstar-36422e6e.as43234.net] has joined #code
18:35 Attilla_ [Obsolete@Nightstar-36422e6e.as43234.net] has joined #code
18:35 eckse [eckse@Nightstar-086443b9.dsl.sentex.ca] has joined #code
18:35 mode/#code [+o eckse] by ChanServ
18:38 Attilla [Obsolete@Nightstar-36422e6e.as43234.net] has quit [Ping timeout: 121 seconds]
18:40 Kindamoody is now known as Kindamoody[zZz]
19:01 Rhamphoryncus [rhamph@Nightstar-5697f7e2.abhsia.telus.net] has quit [Ping timeout: 121 seconds]
19:04 Stalker [Z@Nightstar-5aa18eaf.balk.dk] has joined #code
19:07 Attilla_ is now known as Attilla
19:16 Vornucopia [NSwebIRC@C888DE.7F9621.4A1301.BBBE7B] has joined #code
19:16 Rhamphoryncus [rhamph@Nightstar-5697f7e2.abhsia.telus.net] has joined #code
19:21 Rhamphoryncus [rhamph@Nightstar-5697f7e2.abhsia.telus.net] has quit [Ping timeout: 121 seconds]
19:22 Rhamphoryncus [rhamph@Nightstar-5697f7e2.abhsia.telus.net] has joined #code
19:39
< Vornucopia>
Gnah. Doing this without an actual set class is a pain
19:42 maoranma [maoranma@Nightstar-b802c0c9.pools.spcsdns.net] has joined #code
19:42
< Vornucopia>
(prime number generation via seiving)
19:43
< Vornucopia>
(sieving, I can spell)
19:43
< maoranma>
Allegedly
19:46
<@jerith>
Vornucopia: What language?
19:46
< Vornucopia>
js, building an app that demonstrates prime factorization.
19:48
< Vornucopia>
I have some parts of a js set implementation floating around somewhere.
19:48
< maoranma>
I made a function in python that takes an arbitrary coordinate, and prints from top left to bottom right row by row the coordinates between a given range based as if the initial coordinate were the origin
19:51
< Vornucopia>
Though really I guess merge-subtract on sorted arrays would work better.
19:52
< maoranma>
Maybe, it's basically, we have an array of strings, and we wanted only the strings that are a certain distance away from a given point in that array, given in the correct order as a new array
19:53
< Vornucopia>
I think you're misreading my monologue as a response. I can't actually tell what you're doing.
19:53
< maoranma>
def see(ax,ay):
19:53 Attilla [Obsolete@Nightstar-36422e6e.as43234.net] has quit [Client closed the connection]
19:53
< maoranma>
for sy in reversed(range(-5,6)):
19:53
< maoranma>
for sx in range(-5,6):
19:53
< maoranma>
print (sx-ax,sy-ay)
19:54 Attilla [Obsolete@Nightstar-36422e6e.as43234.net] has joined #code
19:54
< Vornucopia>
So you're showing the 11 x 11 range around the origin, except as offsets from a different location.
19:54 Attilla [Obsolete@Nightstar-36422e6e.as43234.net] has quit [Client closed the connection]
19:55
< maoranma>
Yes, that's a much better definition than the one I offered.
19:55
< Vornucopia>
Not necessarily, but the fact that you agreed means I got it. :)
19:56 Attilla [Obsolete@Nightstar-36422e6e.as43234.net] has joined #code
19:56
< maoranma>
It's our lab practum for our intro to programming class, we're making a silly little tank game in python
19:57
< Vornucopia>
Are you going to call it WOMBAT
19:57
< maoranma>
Haha, I'll suggest that to Philip
19:58
< maoranma>
He have four in our group (two too many imo -_-)
19:58
<@jerith>
21:52 < mithrandi> * cmccann: Ruby is a fine language if you're secretly a lisp
19:58
<@jerith>
21:52 < mithrandi> programmer but want to hide behing perl and smalltalk so nobody
19:58
<@jerith>
21:52 < mithrandi> catches you
19:59
< Vornucopia>
Heh
19:59
< maoranma>
Philip is doing our core coding, and I'm doing machanics, and our VC guy is doing our "graphics" and arena
19:59
< maoranma>
And our fourth guy will have his name on it somewhere
20:00
<@jerith>
VC guy?
20:00
< maoranma>
Visual communications
20:19 Attilla_ [Obsolete@Nightstar-36422e6e.as43234.net] has joined #code
20:20 Attilla [Obsolete@Nightstar-36422e6e.as43234.net] has quit [Ping timeout: 121 seconds]
20:21
< Vornucopia>
arg, my kingdom for array-flattening arguments
20:22 Attilla [Obsolete@Nightstar-36422e6e.as43234.net] has joined #code
20:22
< maoranma>
How would I got about doing that merge-subtract array thinging you were talking about?
20:22
<@jerith>
"You can't flatten arrays!" "Yes I can!" "No you can't!"
20:22
< Vornucopia>
maoranma: considering that it wasn't actually about your thing, you wouldn't, well, okay, let me code it and show you.
20:22
< maoranma>
lol, okay
20:23 Attilla_ [Obsolete@Nightstar-36422e6e.as43234.net] has quit [Ping timeout: 121 seconds]
20:26 Attilla [Obsolete@Nightstar-36422e6e.as43234.net] has quit [Ping timeout: 121 seconds]
20:27 Attilla [Obsolete@Nightstar-36422e6e.as43234.net] has joined #code
20:31
< Vornucopia>
http://pastebin.starforge.co.uk/496 Very simple implementation; takes two sorted arrays and returns what's in the first but not the second.
20:31
< Vornucopia>
By putting pushes in different places you can change it to intersection, union, symmetric difference...
20:36
< Vornucopia>
(intersection is just the ==, union is all three; symmetric difference is just the two non-==)
20:38
< maoranma>
Interesting
20:38
< Vornucopia>
Though actually I screwed it up somewhat
20:38
< maoranma>
Is it in pseudocode?
20:39
< Vornucopia>
Javascript
20:39
< maoranma>
Ahh
20:39
< Vornucopia>
There needs to be more loop there though
20:39
< Vornucopia>
If it were pseudocode I'd do it Python shaped
20:40
< Vornucopia>
But the bug here is, if a goes higher than b, then I'll lose all the a stuff after the last b
20:43
< Vornucopia>
http://pastebin.starforge.co.uk/497 so that fixes it.
20:47
< maoranma>
What's a good way to fill an array (or a list of lists?) with empty strings in python quickly?
20:47
< Vornucopia>
1-dimensional, or 2?
20:47
< maoranma>
2
20:48
< Vornucopia>
[["" for y in range(10)] for x in range(10)]
20:49
< maoranma>
And that makes a 10x10 array?
20:49
< Vornucopia>
yep
20:49
< maoranma>
Cool, I'll have to remember that
20:49
< maoranma>
What's with that syntax though?
20:49
< Vornucopia>
List Comprehensions
20:50
< maoranma>
That is apparently new to me
20:50
< Vornucopia>
You also get Generator Expressions that look about the same but give you iterators, use () instead of []; in 2.7 and python3 you get set and dict comprehensions too, using {}.
20:54
< maoranma>
http://pastebin.starforge.co.uk/498
20:54
< maoranma>
There is what we are working on so far
20:55
< maoranma>
And yes, I know his printMap() could've been done with dictionaries better
20:55
< maoranma>
I've already yelled at him to fix that
20:56
< Vornucopia>
Yeah, there's a lot to be fixed in here; might I recommend pulling the pictures into a plain text file?
20:57
< maoranma>
Good idea, I'll fire that at him too
20:57
< Vornucopia>
Simple format, something like "TRW" on one line and then three more lines of the actual picture data
20:58
< Vornucopia>
er, TRC
20:58
< maoranma>
Will have to recontruct it into an array though
20:58
< maoranma>
or matrix, or whatever we're calling them
20:58
< Vornucopia>
Not a problem, that's what your loader function is for.
20:59
< maoranma>
wow, I have a loader function?
20:59
< Vornucopia>
Putting your resources straight into code is foolish.
21:00
< maoranma>
Well sure, I know that
21:00
< maoranma>
What's this about a loader function though? Something I'm about to write?
21:01
< Vornucopia>
Yeah, your loader function takes a resource file and loads it into the running program so it can be used.
21:02
< Vornucopia>
Most programs have quite a few different ones because they deal with many different resources; in your case I suspect you'll have two: one for game boards and one for "graphics"
21:02
< maoranma>
Hmm, can I have it run for as many files it finds in the directory?
21:02
< maoranma>
Or is getting directory info impossible in python?
21:02
< Vornucopia>
os.dir
21:03
< Vornucopia>
but not necessarily a good idea
21:03
< maoranma>
Ah, so I'll just pass the loader function an openfile object?
21:03
< Vornucopia>
Well, okay, don't try to load /everything/
21:03
<&McMartin>
os.walk is also a barrel of laughs (but more often what you want than os.path.walk)
21:04
< Vornucopia>
You'll want to identify what files are actually useful resources for your chosen type
21:04
< Vornucopia>
Which can be done in a variety of ways; extensions is the classic
21:04
< maoranma>
Of course
21:05
< maoranma>
tree.res
21:05
< Vornucopia>
sorry, os.listdir
21:05
< Vornucopia>
That sort of thing, yeah, though a proliferatin of files may not be wise /either/
21:06
< Vornucopia>
Many programs use a single image file for a great variety of different icons, for instance, and just chooses some small portion of that image for each place it needs an icon.
21:06
< maoranma>
A tileset
21:06
< Vornucopia>
Just so.
21:07
< Vornucopia>
you would probably be well served building a tileset "image" for your game
21:08
< Vornucopia>
Though I'd make it more like
21:08
< Vornucopia>
mmh, one moment
21:08
< maoranma>
heh
21:09
< Vornucopia>
Also, um
21:09
< Vornucopia>
Why does the left tank point right but the right tank point left
21:10
< maoranma>
Haha, because Philip is an idiot
21:11
< Vornucopia>
ah, fucking thing, pastebin eats double @s because it assumes that no language uses them
21:12
< Vornucopia>
Which is bad when you're doing ascii art, but actually /fatal/ when you're doing ruby. TheWatcher TheWatcher TheWatcher, line above notes misfeature in pastebin
21:12
< maoranma>
lol
21:13
< Namegduf>
s/pastebin/Ruby/
21:13
< Namegduf>
Sorry, had to. XD
21:13
< Vornucopia>
No, it's sensibly used in Ruby
21:13
< maoranma>
Plain text should be okay?
21:13
< maoranma>
Syntax Highlighting = None
21:13
< Vornucopia>
No, no, Ruby uses @@ sensibly
21:13
< maoranma>
I should say
21:14
< maoranma>
I mean to prevent pastebin from eating @@'s
21:14
< Vornucopia>
Nope, I had it on None
21:14
< maoranma>
Huh
21:14
< Vornucopia>
But @@ is the "class" variable-scoping wart
21:15
< Vornucopia>
http://pastebin.starforge.co.uk/501 here's a sample of the file
21:17
< maoranma>
Ahh, so I read every 4 lines, pass it to the loader function to make it into an array for the code
21:18
< Vornucopia>
Well, you hand the loader function a filename, the loader opens the file and hands out 4-line chunks to the resource preparation function, and then the loader finally returns with a dictionary or similar of the resources it loaded
21:18
< maoranma>
Hmhmm
21:19
< maoranma>
Yea, dictionary would be pretty
21:21
< Vornucopia>
(also I feel like I'm talking at least somewhat out of my ass here; I'm an experienced programmer but not in this field. On the other hand, McM hasn't come in and told me I'm wrong yet and he's actually done this sort of thing, so I think I'm doing all right)
21:21
< maoranma>
It sounds reasonable to me
21:29 maoranma [maoranma@Nightstar-b802c0c9.pools.spcsdns.net] has quit [Ping timeout: 121 seconds]
21:30
<&McMartin>
Vorn: I haven't reviewed you yet, don't take my silence as consent~
21:30
< Vornucopia>
hahaha
21:33 maoranma [maoranma@D5CC77.617194.D31872.BA8A50] has joined #code
21:34
< maoranma>
Grah
21:34
< maoranma>
phone was not plugged in apparently
21:34
< maoranma>
Anyway
21:35
< maoranma>
]16:27[ <maoranma> Okay, so os.listdir('path') returns a list of files, so to get only files that end in the extention I want, I'd use some sort of list comprehension?
21:35
< Vornucopia>
I'd go something like, um, let's see
21:35
< Vornucopia>
[f for f in os.listdir(path) if f.endswith(".res")]
21:36
< Vornucopia>
note that different types of resources will want to have different extensions if you're doing it this way, obviously
21:36
< maoranma>
Right
21:37
< maoranma>
Lovely
21:37
< maoranma>
Listcomp is handy stuff
21:37
< Vornucopia>
Very very handy stuff
21:40
< maoranma>
I also found out about vars()
21:41
< maoranma>
Which is like some kind of super dictionary of all the variables in a particular scope
21:41
< Vornucopia>
No No No Bad Wrong Evil
21:41
< maoranma>
hahahaha
21:42
< Vornucopia>
Do not use reflection for something like this.
21:42
< maoranma>
Reflection, is that what it's called?
21:43
< Vornucopia>
Generally
21:43
< Vornucopia>
Don't use it unless you really need to.
21:44
< Vornucopia>
You almost never need to.
21:44
< maoranma>
I can't imagine where I would really NEED it
21:44
< maoranma>
But it's fun for string formating
21:44
< Vornucopia>
NO BAD WRONG EVIL
21:44
< maoranma>
HAHAHA
21:46
< maoranma>
lol = {'but': 'Vorn', 'why': 'hates', 'not': 'me'}
21:47
< maoranma>
print '%(but)s %(why)s %(not)s' % vars()
21:48
<&McMartin>
The rule for reflection in Python is simple
21:48
<&McMartin>
If you speak the name of hasattr() three times, the King in Yellow will show up and devour your soul.
21:48
<&McMartin>
Keep it under three and you've probably encapsulated it sufficiently~
21:49
< Vornucopia>
Heh
21:49
<&McMartin>
(One place in Python where reflection is Actually The Right Choice, where it usually isn't, is for implementing the Visitor pattern.)
21:50
< Vornucopia>
All right, time for me to go back to work, or so
21:52 Vornucopia [NSwebIRC@C888DE.7F9621.4A1301.BBBE7B] has quit [[NS] Quit: Page closed]
21:55
< maoranma>
print('{lol[but]} {lol[why]} {lol[not]}'.format(**vars()))
21:55
< maoranma>
There, now it'll actually run, hah
21:58
<&McMartin>
See, that would be more efficient if you applied **lol instead of **vars().
22:00
< maoranma>
True, it's more useful if the info is in several variables that aren't dictionarys
22:00
< maoranma>
And by more useful, I mean, makes Vorn hate me
22:01
<&McMartin>
It's better to just build a dictionary outright.
22:01
<&McMartin>
That way you can pass it around without fucking with interpreter internals.
22:01
< maoranma>
What's the visitor pattern btw?
22:06
<&McMartin>
That's too long to go into at the moment (I don't have much time before my work requires attention instead of letting robots run)
22:06
<&McMartin>
But it's basically a trick to give you the effect of multiple "this" pointers.
22:06
< maoranma>
Hmm, okay
22:07
<&McMartin>
The basic OO thing is you have a special argument (this) and when you call a method (foo) with this->foo() which function gets called depends on the type of "this"
22:07
<&McMartin>
There is a mechanism called "multiple dispatch", which basically only Common LISP uses directly, where you can have make which function it is depend on the type of arguments in addition to "this".
22:07
<&McMartin>
Visitor is a way of implementing multiple dispatch when your language doesn't support it.
22:08
<&McMartin>
The most common case for me is when writing a program analyzer or something, where the program is a tree of, say, SyntaxNode and I have a set of Pass objects that run across it
22:08
<&McMartin>
Conceptually what I want is a bunch of functions, each equivalent to a dispatch on Pass subclass and SyntaxNode subclass simultaneously.
22:09
<&McMartin>
Using reflection in Python lets you handle default cases more cleanly
22:09
<&McMartin>
Wiki's page is silly, but: http://en.wikipedia.org/wiki/Visitor_pattern
22:17 * TheWatcher readsup
22:17
<@TheWatcher>
Eugh
22:17
<@TheWatcher>
I really need to fix up that pile of shit
22:17
< maoranma>
Vorn broke it!
22:17 * maoranma <innocent>
22:25
< RichyB>
McMartin, if you dig up "zope component architecture" you'll find that someone implemented a close approximation to multimethods in Python.
22:26
< RichyB>
"Multi-adapters", dispatching on interfaces.
22:27
<&McMartin>
I'd have to dig into that, I think
22:27
<&McMartin>
I usually compare multimethods to the sorts of tricks I like to play in ML and Haskell with argument pattern matching, though.
22:27
< RichyB>
The implementation is not something that you really want in an inner loop but it isn't offensively slow either, 'tis mostly just a few dict lookups.
22:27
<&McMartin>
Well
22:28
<&McMartin>
When you get down to it, "a few array lookups" is how visitor works.
22:28
<&McMartin>
Unless it's Smalltalk, in which case it's a few dict lookups >_>
22:28
<&McMartin>
Inform 7's approach is closer to ML's.
22:29
< maoranma>
"First, distract target, then block his blind jab, counter with cross to left cheek. Discombobulate. Dazed, will attempt wild haymaker. Employ elbow block, and body shot. Block feral left, weaken right jaw, now fracture. Break cracked ribs, traumatize solar plexus, dislocate jaw entirely. Heel kick to diaphragm. In summary; ears ringing, jaw fractured, three ribs cracked, four broken, diaphragm
22:29
< maoranma>
hemmoraging. Physical recovery, six weeks. full psychological recovery, six months. Capacity to spit at back of head: neutralized."
22:29
< maoranma>
Victorian Superhero Shelock Holmes is badass.
22:30
< RichyB>
Psychopathic and verbose.
22:33 RichyB [MyCatVerbs@Nightstar-3b2c2db2.bethere.co.uk] has quit [[NS] Quit: Leaving]
22:50
< ToxicFrog>
McMartin: what is the key difference between multiple dispatch and, say, C++ method overloading?
22:53
<&McMartin>
TF: method overloading is non-virtual.
22:54
<&McMartin>
If you say c->foo(a), and a is of class B extends A, then multiple dispatch produces the (C, B) method call, where overloading will give you the (C, A) one.
22:54
<&McMartin>
Or rather A is a pointer to A, but is actually pointing at B extends A
22:55
<&McMartin>
You can't use overloading to say "iterate through this list and apply this pass appropriately to each child it has"
22:55
<&McMartin>
Well. Without rearchitecting it to use single dispatch, or without doing a visitor-like trike.
22:55
< ToxicFrog>
Aah.
22:59
<&McMartin>
ML and Haskell, on the other hand, is basically doing an explicit type-switch, because polymorphism in those languages looks more like a union with a field that indicates which field to use than like an array full of function pointers.
23:01 * ToxicFrog nods
23:01
< ToxicFrog>
I keep forgetting that C++ overloads are resolved at compile time by declared type
23:11 Stalker [Z@Nightstar-5aa18eaf.balk.dk] has quit [[NS] Quit: ]
23:23 You're now known as TheWatcher[T-2]
23:25 You're now known as TheWatcher[zZzZ]
23:46 Stalker [Z@Nightstar-3602cf5a.cust.comxnet.dk] has joined #code
--- Log closed Thu Feb 23 00:00:57 2012
code logs -> 2012 -> Wed, 22 Feb 2012< code.20120221.log - code.20120223.log >

[ Latest log file ]