code logs -> 2013 -> Thu, 14 Feb 2013< code.20130213.log - code.20130215.log >
--- Log opened Thu Feb 14 00:00:54 2013
00:15 RichyB [richardb@Nightstar-3b2c2db2.bethere.co.uk] has quit [[NS] Quit: >:3 This is BunThulhu. Copy him into your quit message to help him take over the Internet.]
00:28 thalass [thalass@Nightstar-23c59d3f.bigpond.net.au] has quit [Ping timeout: 121 seconds]
00:29 thalass [thalass@Nightstar-23c59d3f.bigpond.net.au] has joined #code
00:39 Derakon[AFK] is now known as Derakno
00:39 Derakno is now known as Derakon
00:43 himi [fow035@D741F1.243F35.CADC30.81D435] has joined #code
00:43 mode/#code [+o himi] by ChanServ
00:57 You're now known as TheWatcher[T-2]
01:13 You're now known as TheWatcher[zZzZ]
01:14 celticminstrel [celticminst@Nightstar-e83b3651.cable.rogers.com] has joined #code
01:15 mode/#code [+o celticminstrel] by ChanServ
01:33 mac [mac@Nightstar-cb5f6d54.cc.il.us] has quit [[NS] Quit: This computer has gone to sleep]
02:08 Attilla [Attilla@Nightstar-aced750e.range86-184.btcentralplus.com] has quit [Ping timeout: 121 seconds]
03:02 Kindamoody[zZz] is now known as Kindamoody
03:36 himi [fow035@D741F1.243F35.CADC30.81D435] has quit [Client closed the connection]
03:36 himi-cat [fow035@D741F1.243F35.CADC30.81D435] has joined #code
03:37 mode/#code [+o himi-cat] by ChanServ
03:39 thalass [thalass@Nightstar-23c59d3f.bigpond.net.au] has quit [Operation timed out]
03:58 mac [mac@Nightstar-fe8a1f12.il.comcast.net] has joined #code
04:04 mac [mac@Nightstar-fe8a1f12.il.comcast.net] has quit [[NS] Quit: Leaving]
04:10 Typherix [Typherix@Nightstar-7dc8031d.mi.comcast.net] has joined #code
04:25 VirusJTG [VirusJTG@Nightstar-09c31e7a.sta.comporium.net] has quit [[NS] Quit: Program Shutting down]
04:59 Reivdroid [Reiver@5B433A.3CF6C7.4A1EAD.B2693A] has joined #code
05:08 Reivdroid [Reiver@5B433A.3CF6C7.4A1EAD.B2693A] has quit [Ping timeout: 121 seconds]
05:54 ErikMesoy|sleep is now known as ErikMesoy
06:07 celticminstrel [celticminst@Nightstar-e83b3651.cable.rogers.com] has quit [[NS] Quit: And lo! The computer falls into a deep sleep, to awake again some other day!]
06:22 Kindamoody is now known as Kindamoody|out
06:27 Derakon is now known as Derakon[AFK]
06:54
<~Vornicus>
RichyB: that lambdabot line makes my brain curdle.
07:05 himi-cat [fow035@D741F1.243F35.CADC30.81D435] has quit [Ping timeout: 121 seconds]
07:33
<&McMartin>
Hrm
07:33 * McMartin pokes at Spellcast
07:33
<&McMartin>
OK, this is slightly more complex than I had hoped.
07:33
<&McMartin>
I need to sneak in some extra data in the result.
07:37
<&McMartin>
I need to specify whether a spell that one hand completed used both in the last move.
07:49
< Reiver>
?
08:01 * McMartin is writing a Clojure evaluator for Spellcast gestures.
08:51 Orthia [orthianz@3CF3A5.E1CD01.5A78C0.03128C] has quit [[NS] Quit: Going dooooown...]
08:59 himi-cat [fow035@Nightstar-5d05bada.internode.on.net] has joined #code
08:59 mode/#code [+o himi-cat] by ChanServ
09:03 Orthia [orthianz@3CF3A5.E1CD01.5A78C0.03128C] has joined #code
09:03 mode/#code [+o Orthia] by ChanServ
09:07
<&McMartin>
OK, I think that's got it
09:09
<&McMartin>
ToxicFrog: http://pastebin.starforge.co.uk/551
09:09
<&McMartin>
Others may care, but mostly him~
09:10 You're now known as TheWatcher
09:10
<&McMartin>
(Spellcast spell identifier in Clojure)
09:10
<&McMartin>
(In 78 lines, 46 of which are just the copied spell list)
09:15
< Reiver>
Anyone familiar with EndNote?
09:44 froztbyte [froztbyte@Nightstar-dc394964.za.net] has quit [Ping timeout: 121 seconds]
09:44 froztbyte [froztbyte@Nightstar-dc394964.za.net] has joined #code
09:44 mode/#code [+o froztbyte] by ChanServ
10:01 EvilDarkLord [jjlehto3@Nightstar-a5db08cc.org.aalto.fi] has quit [Ping timeout: 121 seconds]
10:01 EvilDarkLord [jjlehto3@Nightstar-a5db08cc.org.aalto.fi] has joined #code
10:03
<&McMartin>
http://www.zazzle.com/game_designer_bomb_squad_t_shirt-235053855613845060
10:07
<@Tarinaky>
Oh dear Lord save me from this lecture on turing machines.
10:10
<@Azash>
What's wrong with Turing machiens?
10:10
<@Azash>
s/en/ne/
10:11
<@Tarinaky>
Nothing.
10:11
<@Tarinaky>
This lecture on the other hand~
10:11
<@Azash>
Ah
10:15
<@TheWatcher>
Best thing to do with turing machine lectures?
10:15
<@TheWatcher>
Put a tape recorder at the front of the lecture theater, set it going, walk out again.
10:16
<@TheWatcher>
That way you avoid the inevitable boredom, and get to be sarcastically meta too.
10:19
<@Tarinaky>
Oh goodie, she's giving us the plague.
10:19 RichyB [richardb@Nightstar-3b2c2db2.bethere.co.uk] has joined #code
10:20
<~Vornicus>
the plague?
10:21
< Syk>
yaaaay plague
10:21
<@Tarinaky>
I am unsure how to clarify this.
10:22
<@Tarinaky>
Sickness?
10:22
<@Tarinaky>
Malady?
10:22
<@TheWatcher>
Galloping lurgy?
10:22
<~Vornicus>
And "she" is... the lecturer?
10:23
<@Tarinaky>
Yes.
10:25 RichyB [richardb@Nightstar-3b2c2db2.bethere.co.uk] has quit [Ping timeout: 121 seconds]
10:29 thalass [thalass@Nightstar-23c59d3f.bigpond.net.au] has joined #code
10:36
< Xires>
anyone have a recommendation for a lexical generator other than flex?
10:55 Attilla [Attilla@Nightstar-aced750e.range86-184.btcentralplus.com] has joined #code
11:08
<@Tarinaky>
Oestensibly there isn't one. If your language has decent string manipulation a tokoniser isn't that hard.
11:09
<@Tarinaky>
*tokeniser
11:10 RichyB [richardb@Nightstar-3b2c2db2.bethere.co.uk] has joined #code
11:12
<@Tarinaky>
It's the grammar that's difficult.
11:29
< Xires>
Tarinaky; ty..flex works fine and that's what's currently being used but I thought it'd be nice to know if others had recommendations for something that they liked better
11:33 thalass [thalass@Nightstar-23c59d3f.bigpond.net.au] has quit [Ping timeout: 121 seconds]
11:51
< ErikMesoy>
Ooooh... interesting. Attempting to get 2 values from a Python function that returns 3 fails. Attempting to get 3 from a function that returns 2 fails. Attempting to get 1 value from a function that returns 2 not only works, but gets something of a different type than the return values.
11:51
< ErikMesoy>
Well. That explains a bunch of issues I was chasing down.
11:51
<@TheWatcher>
O.o
11:51
<@TheWatcher>
Weird
11:52
< ErikMesoy>
def foo(): return 1,2
11:52
< ErikMesoy>
j,k = foo()
11:52
< ErikMesoy>
j is now 1, k is 2.
11:52
< ErikMesoy>
j = foo()
11:52
< ErikMesoy>
j is now the tuple (1,2).
11:52
<@Azash>
Are you getting some sort of tuple?
11:52
<@Azash>
Yeah
11:52
<@Azash>
Makes sense
11:53 thalass [thalass@Nightstar-23c59d3f.bigpond.net.au] has joined #code
11:53
< ErikMesoy>
Makes sense in retrospect. Quietly covered up an issue where I assume that a mismatch between returns and gets would yield an error.
11:53
< ErikMesoy>
*assumed
12:09
< ErikMesoy>
Lesson of the day: sometimes Python assumes implicit parentheses around comma-separated things.
12:17 Vornicus [vorn@ServerAdministrator.Nightstar.Net] has quit [[NS] Quit: Leaving]
12:43 Nemu [NeophoxProd@Nightstar-ff705a95.asahi-net.or.jp] has quit [Client closed the connection]
12:44 Nemu [NeophoxProd@Nightstar-2b760d9b.asahi-net.or.jp] has joined #code
13:06
<@Tarinaky>
I have a Windows program, that I want to run in WINE.
13:06
<@Tarinaky>
But because of the vagueries of the network I am (very restrictive firewall) I need to proxy my traffic through SOCKS.
13:06
<@Tarinaky>
/Apparently/ tsocks doesn't play nice with Wine.
13:07
<@Tarinaky>
Does anyone have any suggestions for socksification with WINE?
13:08
< RichyB>
ErikMesoy: def foo(): return (1,)
13:08
< RichyB>
ErikMesoy: j = foo()
13:08
< RichyB>
ErikMesoy: j is now a 1-tuple ?
13:09
< RichyB>
Python doesn't have multiple-return-values, it actually just has a syntactic shortcut for returning a tuple with a fixed number of elements and another for syntactic shortcut for unpacking a tuple with a fixed number of elements.
13:13
<@RobinStamer>
Tarinaky: Run the SOCKS on the Linux side?
13:14
<@Tarinaky>
I... am.
13:14
<@Tarinaky>
Or rather, I am running the socks server on the Linux side.
13:14
<@RobinStamer>
Ah
13:15 * RobinStamer wonders how tsocks doesn't work with wine then. Since there's no way for it to detect that...
13:16
<@Tarinaky>
Well according to google apparently it's something to do with how Wine emulates windows socket API or something.
13:16
<@Tarinaky>
Meaning that it only socksifies the first request or something.
13:16
< ErikMesoy>
interesting how (1) is 1, but (1,) and (1,2) and (1,2,) are all tuples
13:16
<@Tarinaky>
In practice all I can say is I'm getting the "Does not work" error.
13:18
<@RobinStamer>
Not really. (1) is just the literal 1, surrounded by parens. (1,) is a tuple as that's how they chose to mark something as such.
13:18
<@RobinStamer>
T: No clue
13:18
<@RobinStamer>
Never had to debug anything in wine, or used SOCKS
13:19
<@RobinStamer>
Stupid suggestion: relay everything through stunnel twice (encrpyt then decrypt), then socks?
13:20
<@RobinStamer>
Oh, wait, wine is doing SOCKS itself?
13:22
< ShellNinja>
A youtube video linking to a text document which holds the link to a torrent file that points to what you want to get. Right.
13:23
<@RobinStamer>
Wait what?
13:23
<@Tarinaky>
If WINE did SOCKS itself that'd be awesome.
13:28
< ShellNinja>
RobinStamer: Just something I stumbled upon.
13:31
< ErikMesoy>
Security by obscurity?
13:49
<@gnolam>
http://www.i-programmer.info/news/144-graphics-and-games/5450-can-you-do-the-reg ular-expression-crossword.html
13:50
< Xon>
gnolam, that's been going around my office for the last few days now
13:50
< Xon>
utterly crazy
14:22
<@Azash>
Is it the hexagon one?
14:39
< ErikMesoy>
Does Python have anything like "default return values" similar to function arguments, to be used when returning more than one but not a fixed number of things?
14:39
< ErikMesoy>
Similar to default function arguments, that is.
14:40
<@Tarinaky>
I am not sure I understand the question. Every function, in Python, implicitly returns None if nothing else is returned.
14:40
< ErikMesoy>
I mean that I can have a function that's written to return 3 or 4 things in different branches; if it reaches a point where it would "return foo, bar, baz" it also returns a 4th.
14:43
< ErikMesoy>
function(i,j,k, z=100) can be called with 3 or 4 arguments; if called with three arguments, it pretends it was called with 100 as the fourth argument. I'm wondering if there's a way to smiliarly say return with three arguments and return a fourth default as well.
14:43
< RichyB>
There isn't. Return four arguments and leave the last one none.
14:44
< RichyB>
Well
14:44
< RichyB>
You would have to wrap the function, a decorator would make the syntax for that sensible.
14:45
< RichyB>
@default_return_values(3, "weasels"); def foo(x): { if (x) { return "stomp", "on"; } else { return "stomp", "on", "x"; }
14:46
< RichyB>
replace ; with newlines and { } with indents and deindents
14:46
< RichyB>
ugh, pastebin...
14:46
< ErikMesoy>
I see.
14:51 thalass [thalass@Nightstar-23c59d3f.bigpond.net.au] has quit [Ping timeout: 121 seconds]
14:52
<&jerith>
That strikes me as a bit silly.
14:52
<&jerith>
Rather just put "return blah" at the bottom of the function.
14:54
< RichyB>
I'd rather just return the same number of values everywhere.
14:55
<&jerith>
Oh, wait. I misunderstood.
14:55
<&jerith>
You want to add things to various return values.
14:55
<&jerith>
Yeah, do that explicitly rather.
14:57
< ErikMesoy>
I may end up rewriting this, but the current context is that I may want to return a whole host of things and most of them should go to a default value.
14:58
< ErikMesoy>
e.g. in a game interaction, talking to an NPC might result in magical training, and then the dialogue bit shouldn't have direct access to the PC stats. Instead the dialogue returns "amount_to_raise_magic=1" and the main handler passes that on to stats.
14:58
< ErikMesoy>
So a lot of dialogue will be returning amount_to_raise_various=0 to the main handler
14:58
<&jerith>
ErikMesoy: Then I think you want to return an object that you construct.
14:58
<@Azash>
Does python do ref-
14:58
<@Azash>
Yeah
14:58
<&jerith>
The constructor can have default params.
14:59
< RichyB>
http://pastebin.starforge.co.uk/552 kind of gack.
15:00
<&jerith>
ErikMesoy: Something like we did in http://www.suspended-sentence.org/trac/browser/pyntnclick/pyntnclick/state.py#L1 4
15:05
< ErikMesoy>
I'll take some time to read and think about that. (Dialogue engine really shouldn't have stat access, right?)
15:06
<&jerith>
Depends. Are stats ever relevant to conversations?
15:07
< ErikMesoy>
Not presently. I have no plans for Fallout's retard-dialogue-options. :p
15:10
< Xon>
booo!
15:11
< ErikMesoy>
I'm not sure if booing at me will change my plans.
15:16
< Xon>
dialogue-options being unrelated to character stats or history is going to be rather static. just as long as you realise changing that after the fact will be horrible
15:27
<@RobinStamer>
I also suggest returning an object
15:40
< ErikMesoy>
Right, I can see the argument that dialogue should have read access to stats. Still dubious about write.
15:41 * ErikMesoy reads jerith's code some more.
15:46 gnolam [lenin@Nightstar-fe1ac75d.cust.bredbandsbolaget.se] has quit [[NS] Quit: Das Reboot]
15:51 gnolam [lenin@Nightstar-fe1ac75d.cust.bredbandsbolaget.se] has joined #code
15:51 mode/#code [+o gnolam] by ChanServ
15:54 * Azash finishes the regexp grid
16:01 ShellNin1a [abudhabi@Nightstar-19ac0f3b.adsl.inetia.pl] has joined #code
16:03 ShellNinja [abudhabi@Nightstar-37cb24eb.adsl.inetia.pl] has quit [Ping timeout: 121 seconds]
16:09 d4de [olorin@687AAB.418D22.A66DA1.CC1B39] has quit [Ping timeout: 121 seconds]
17:08 d4de [olorin@687AAB.E04ECC.3FC37D.EC8316] has joined #code
17:20 Derakon [chriswei@Nightstar-a3b183ae.ca.comcast.net] has joined #code
17:20 mode/#code [+ao Derakon Derakon] by ChanServ
17:20 * Derakon mutters at one of the machines at work.
17:20
<&Derakon>
Yesterday I rebooted it and it took hours to come back up.
17:20
<&Derakon>
It did come back up, so foolishly I thought the problem had perhaps gone away and rebooted it again today, but it's been 75 minutes and it's still inaccessible.
17:21
<&Derakon>
Hooked up a display to it; nothing shown, just a black screen.
17:21
<&Derakon>
(Windows XP box)
17:22 Syk is now known as syksleep
17:22
< syksleep>
as a windows 7 administrator I have this to say
17:22 * syksleep hits it with a fire extinguisher
17:23
<&Derakon>
Heh.
17:23
<&Derakon>
I honestly can't remember why this particular machine is running XP instead of something newer.
17:24
<&Derakon>
But we have machines running Win2k because they work and nobody wants to risk breaking the microscope for an unnecessary upgrade.
18:14 Kindamoody|out is now known as Kindamoody
18:23 celticminstrel [celticminst@Nightstar-e83b3651.cable.rogers.com] has joined #code
18:23 mode/#code [+o celticminstrel] by ChanServ
18:49 Courage [Moltare@583787.FF2A18.190FE2.4D81A1] has quit [Ping timeout: 121 seconds]
18:49 Courage [Moltare@583787.FF2A18.190FE2.4D81A1] has joined #code
18:49 mode/#code [+o Courage] by ChanServ
18:50 Kindamoody is now known as Kindamoody|afk
18:54 himi-cat [fow035@Nightstar-5d05bada.internode.on.net] has quit [Ping timeout: 121 seconds]
19:14
<@celticminstrel>
Okay, I have saving implemented and pushed...
19:14
<@celticminstrel>
Hopefully it works properly...
19:17 Kindamoody|afk is now known as Kindamoody
19:29 Kindamoody is now known as Kindamoody[zZz]
19:36
<@Rhamphoryncus>
Derakon: so.. rather than risk breaking a microscope they pretty much guarantee breaking a microscope
19:37
<@celticminstrel>
???
19:37
<@Rhamphoryncus>
celticminstrel: talking about upgrading an old box vs not
19:52
< ErikMesoy>
If I have a container of NPCs who are each of slightly different classes (hur hur) and I want to get out an old NPC rather than create a new duplicate, is there a cleverer way to do it than iterating isinstanceof() over the container?
20:02
<@Namegduf>
Seems like a reasonable thing to do. The usual anti-pattern that occurs trying to avoid that, is to add your own type-getter to the superclass and have the derived classes implement it- which is just reimplementing instanceof() yourself to avoid it.
20:03 Vornicus [vorn@ServerAdministrator.Nightstar.Net] has joined #code
20:03 mode/#code [+qo Vornicus Vornicus] by ChanServ
20:03
<@Namegduf>
It's basically just like any other case of iterating a bunch of things which have individual keys in a list, and pulling out the one with the right key. The key in this case is just the class.
20:04
< ErikMesoy>
Ick, that sounds silly. What I was considering to avoid it was to move all NPC flags to a global storage and recreate the NPC each time but let the NPC get its continuity from the data in the storage.
20:05
< ErikMesoy>
("that" being the anti-pattern you described)
20:05
<@Namegduf>
It is pretty silly, yeah.
20:17 * ErikMesoy self. self. self. self. self. in so many classes
20:18
<&Derakon>
You could make your container be a map of class type to list of instances.
20:19
< ErikMesoy>
Not familiar with map, is it like dict?
20:21
<&Derakon>
Yeah, "hash map" is the more general term for dict.
20:38
<@Rhamphoryncus>
mapping is the more general term. hash is a specific form
20:38
<@Rhamphoryncus>
Well, dict and mapping are about as general, but mapping is more common
20:41
<&McMartin>
Yeah, a map is a set of key-value pairs, more or less.
20:41
<@Rhamphoryncus>
Associative array is another such term. Wikipedia lists associative array, map, and dictionary as synonyms
20:41
<&McMartin>
"hash map" is a specific way of implementing that
20:41
<&McMartin>
Which is, in particular, unordered.
20:42
<&McMartin>
Ordered maps generally involve the red-black balanced binary tree algorithm and speaking as a credentialed CS academic the correct way to implement red-black trees is to copy somebody else's working published design.
20:42
<@Rhamphoryncus>
lol
20:43
<@Rhamphoryncus>
s/generally/typically/
20:43
<&McMartin>
Fair enough
20:45
<@Rhamphoryncus>
And to be more pedantic you also have to distinguish a mapping that merely retains order from one that's inherently sorted. The latter is almost always the intended meaning
20:45
<&McMartin>
Not sure what you mean by "retains order" - do you mean there "stuff comes out in the order it went in"?
20:46
<@Rhamphoryncus>
yes
20:46
<&McMartin>
Because I don't call that "ordered"~
20:46
<@Rhamphoryncus>
http://docs.python.org/2/library/collections.html#collections.OrderedDict
20:47
<&McMartin>
Yeah, that doesn't match the way I'd describe it though I realize it works.
20:47
<&McMartin>
If someone were to claim "ordered but unsorted" I would assume some kind of multimap.
20:47
<@Rhamphoryncus>
That's why I mention it.
20:47
<&McMartin>
What is the use case for this type?
20:48
<@Rhamphoryncus>
I don't recall
20:48
<~Vornicus>
ErikMesoy: I don't know why you're complaining about self
20:48
<~Vornicus>
At all.
20:49
<@Rhamphoryncus>
Huh. C++'s "multimap" is sorted while you need "unordered_multimap" to avoid sorting. To me a multimap *only* implies multiple values per key
20:50
<@Rhamphoryncus>
(And there's plenty of multimap hashtable designs)
20:51
<&McMartin>
All of C++'s standard maps are sorted.
20:51
<&McMartin>
This is because operator< is part of the language but hashCode() is not~
20:51
<&McMartin>
No, really, that is the reason.
20:51
<@Rhamphoryncus>
heh
20:51
<&McMartin>
IIRC the unordered maps are part of a later standard nobody implements quite yet.
20:51
<@Rhamphoryncus>
That's such an asinine reason.. perfect C++.
20:52
<@gnolam>
unordered_map is part of C++11.
20:52
<@gnolam>
But has been implemented for quite a while in the major compilers.
20:52
< ErikMesoy>
Vornicus: I can't tell if you're being sarcastic
20:53 mac [mac@Nightstar-fe8a1f12.il.comcast.net] has joined #code
20:53 * Derakon reads up.
20:53
<&Derakon>
I've used OrderedDict for serialization work.
20:53
<@Rhamphoryncus>
ErikMesoy: are you complaining about the verbosity or the lack of ambiguity?
20:53
<&Derakon>
For example, in Pyrel we want each creature record to start out with the creature's name, graphical display info, and allocation rules (native depth, rarity) before getting into the creature's stats and flags.
20:55
<&Derakon>
Similarly, in UI work sometimes I want a mapping of e.g. button labels to actions for those buttons, and I want to use the same structure to actually construct the UI, so I need to maintain order.
20:55
< ErikMesoy>
Rhamphoryncus: Mostly the verbosity.
20:56
<@Rhamphoryncus>
ErikMesoy: fair enough, it is a nuisance.
20:57 himi [fow035@Nightstar-5d05bada.internode.on.net] has joined #code
20:57 mode/#code [+o himi] by ChanServ
20:58
< ErikMesoy>
I sorta wish classes could have scope for variables the way functions do.
20:58 ShellNin1a is now known as ShellNinja
20:58
< ErikMesoy>
(What would that break, BTW?)
20:58
<&Derakon>
What do you mean, classes have scope for variables?
20:58
<@celticminstrel>
He means implicit "this" as in Java or C++.
20:58
<@celticminstrel>
I think.
20:59
<&Derakon>
So you wouldn't have to type "self." all the time? Ewwwwww.
20:59
<@celticminstrel>
Yeah.
20:59
<&Derakon>
The fewer scopes you have to remember when working on a bit of code, the better.
20:59
<@celticminstrel>
I generally leave out "this->" in C++ or "this." in Java.
20:59
<&Derakon>
This is why namespaces are a honkin' great idea.
21:00
<&Derakon>
IMO Python does it almost right -- the only un-namespaced code should be the code in the current function. Module-scoped variables should be namespaced in functions in that module IMO.
21:00
<&Derakon>
(So e.g. this would be invalid: "foo = 0; def bar(): print foo", because foo wouldn't be in-scope)
21:01
<@Rhamphoryncus>
ErikMesoy: see, that would be the ambiguity I asked about ;)
21:02
<@Rhamphoryncus>
Derakon: how would that work? You'd have to use a global statement every time? Or would it just be something like curmodule.foo?
21:03
<@celticminstrel>
I think the former?
21:03
<@celticminstrel>
...well, I guess either'd work, wouldn't it.
21:04
<@celticminstrel>
But, the latter would annoy me.
21:04
<&Derakon>
Rhamph: I admit to not having thought about it much, but I guess you'd either use global, or do "import curmodule" at the top of the module.
21:04
<@Rhamphoryncus>
I do wish python had a more explicit concept of module. The current setup is just a heavily-extended single-file scripting mode
21:04
<&ToxicFrog>
Derakon: how do you handle upvalues in that case?
21:04
<&Derakon>
Which I suspect currently is a bad idea.
21:04
<&Derakon>
TF: sorry, upvalue?
21:05
<&McMartin>
It isn't clear in Python whether "x = 3;" means "define a local variable x to 3", "define a field in self to 3", or "define a local variable x to 3, shadowing the field 'x' self happens to have because that's part of a totally different thing it duck types to that you don't care about"
21:05
<&ToxicFrog>
Derakon: local foo = 0; def bar(): print(foo)
21:05
<&ToxicFrog>
Foo is an upvalue of the closure bar.
21:05
<@Rhamphoryncus>
I'd prefer to keep globals as implicit but require explicitly exposing your globals as part of your module
21:05
<&McMartin>
When stuff comes into existence on assignment, you *cannot* have two writable namespaces.
21:05
<&McMartin>
Rhamphoryncus: I'm not talking about gloabls
21:05
<&Derakon>
TF: ah, functions in functions. Hm.
21:06
<&McMartin>
I'm talking about *instance variables* in a hypothetical python where the self. is optional.
21:06
<@Rhamphoryncus>
McMartin: unrelated to what you said. Bad timing, sorry :)
21:07
<&Derakon>
I guess alternately you could have some kind of syntactic sugar that says "I'm starting a new scope here, but I'm bringing in X, Y, and Z from the current scope".
21:07
<&Derakon>
So it'd be like "local foo = 0; def bar() with foo: print(foo)"
21:08
<@Rhamphoryncus>
MyLanguage(TM) was going to have both = and :=, but I forget how they were going to work
21:10
<@Rhamphoryncus>
Ahh, I was going to use := for name binding and = for mutation. Not that it makes sense for python
21:12
<&Derakon>
As a general rule, I want every variable to either be namespaced or to be explicitly brought in somehow (e.g. via "global" or "from foo import bar").
21:12
<&Derakon>
The important thing is that when you see a variable you should be able to readily determine where it came from.
21:13
<@Rhamphoryncus>
I agree with the principle
21:14
<@Rhamphoryncus>
One thing you can do is simply prohibit shadowing of a global with function locals. It's a single file, they're not externally visible, it shouldn't be a big deal
21:14
<&Derakon>
So in other words, "global" variables are automatically in-scope in functions?
21:14
<&Derakon>
That would be an improvement I think.
21:15
<&Derakon>
Since right now they're in this weird semi-read-only state.
21:15
<@Rhamphoryncus>
Not quite. You'd need a global statement to assign to them still.
21:16
<&Derakon>
What would happen if you tried to assign to them without the global statement, though?
21:16
<&Derakon>
Just a syntax error?
21:16
<@Rhamphoryncus>
You do not want "foo = 3" to grab something in an outer scope without you saying so
21:16
<@Rhamphoryncus>
yup
21:17
<&Derakon>
The thing that gets me about globals is that you can modify them without using the "global" statement.
21:17
<&Derakon>
You just can't assign to them.
21:17
<&Derakon>
So e.g. globalVar = {}; def foo(): globalVar[1] = 'a'
21:17
<&Derakon>
That's totally legit and very strange, to me.
21:17
<@Rhamphoryncus>
Yes, but that's mostly a visual distinction
21:18
<@Rhamphoryncus>
And it applies recursively
21:18
<&Derakon>
How do you mean?
21:18
<@Rhamphoryncus>
you might go globalObj.foo.baz.quux[1] = 'a'
21:19
<@Rhamphoryncus>
What you want is distinct syntax for locals vs instance attributes vs globals
21:19
<&Derakon>
I just think it's weird that one form of modifying a global is okay but another is not.
21:19
<@Rhamphoryncus>
So it might be foo for locals, $foo for instance attributes, and &foo for globals
21:19
<@Rhamphoryncus>
I agree
21:20
<@Rhamphoryncus>
With a shared syntax I don't see it as solvable though
21:20
<&Derakon>
Well, it could be solved if global vars were automatically in-scope entirely.
21:21 mac [mac@Nightstar-fe8a1f12.il.comcast.net] has quit [Connection closed]
21:21
<@Rhamphoryncus>
No, it's too easily to forget that a given name has a global, or to add a global when a function already uses that name
21:21
<&Derakon>
Mm.
21:22
<@Rhamphoryncus>
foo[1] = 'a' makes you go "Where is foo defined? I'm clearly not defining it here."
21:24
<@Rhamphoryncus>
(aside: I'd make &foo be outer lexical scope, i.e. for nested functions too. Not allowing shadowing means this is always sufficient.)
21:25
<&Derakon>
The only problem I have with variable glyphs is that they remind me of PHP. >.<
21:25
<&Derakon>
(And Perl, for that matter. They look inelegant)
21:25
<@Rhamphoryncus>
yup :/
21:26
<@Rhamphoryncus>
Could use 'foo instead. Easier to type, doesn't look like either language, and as a bonus it fucks with na?ve editors :D
21:26
<&Derakon>
>.<
21:26
<~Vornicus>
Der: I use global objects occasionally when I need to memoize a function.
21:26
<@Rhamphoryncus>
"That's stupid! I don't care that it works, it's still stupid!" :D
21:33
<&Derakon>
Vorn: I think ideally in that case you'd have a "static" keyword or similar.
21:33
<&Derakon>
But yeah, I don't deny the utility of global variables, I just wish they were easier to track.
21:33 Syloq [Syloq@NetworkAdministrator.Nightstar.Net] has quit [Ping timeout: 121 seconds]
21:34
< ErikMesoy>
Well, that spawned a fascinating discussion.
21:34
<@Rhamphoryncus>
mmhmm
21:34
< ErikMesoy>
I still wish I could declare a variable and modify it inside a class the way I can declare a variable and modify it inside a function. :P
21:35
<@Rhamphoryncus>
ErikMesoy: in python you can..
21:35
<@Rhamphoryncus>
Oh, there are some special scoping rules
21:36
<@Rhamphoryncus>
But CPython actually implements a class declaration as if you called a function and saved the locals
21:38
<@Rhamphoryncus>
Not to mention class decorators in the newest versions
21:38
<@Courage>
As long as the locals are appropriately grateful
21:38
<@Rhamphoryncus>
(And let's not mention metaclasses. They're powerful in the same sense that taking a hexeditor to a compiler is powerful. Euch.)
21:38
<&Derakon>
I've wanted class decorators many times in the past. :(
21:38 Syloq [Syloq@B4EC54.59F324.016BDA.8CB0A3] has joined #code
21:40
<@celticminstrel>
Unbalanced quotes are silly.
21:41 * McMartin sends in the Doily Daleks.
21:41
<&McMartin>
REDECORATE
21:41
<@celticminstrel>
Ergo, Lisp/Logo is silly. :P
21:41
<&McMartin>
They're like primes but backwards
21:42 * Rhamphoryncus does a silly walk
21:43
<@celticminstrel>
I suspect 'foo wouldn't confuse that many editors, especially if they can understand Lisp.
21:44
<@Rhamphoryncus>
celticminstrel: it'd confuse a fair number, but they're not ones designed for source code
21:44
<@Rhamphoryncus>
(well, usually..)
21:44
<&Derakon>
You'd have to re-do vim's syntax highlighters.
21:44 Syloq [Syloq@B4EC54.59F324.016BDA.8CB0A3] has quit [Ping timeout: 121 seconds]
21:44
<&McMartin>
I need to anyway, I name variables things like a'
21:44
<@Rhamphoryncus>
Wait, that makes no sense. If they're just for plain text they wouldn't care about quotes in the first place
21:50 Syloq [Syloq@B4EC54.59F324.016BDA.8CB0A3] has joined #code
21:54 himi [fow035@Nightstar-5d05bada.internode.on.net] has quit [Connection closed]
22:38 Derakon [chriswei@Nightstar-a3b183ae.ca.comcast.net] has quit [[NS] Quit: leaving]
22:53 ErikMesoy is now known as ErikMesoy|sleep
22:58 Syloq is now known as Sy
22:58 Sy is now known as Syloq
22:58 mode/#code [+o Syloq] by ChanServ
23:00 VirusJTG [VirusJTG@Nightstar-09c31e7a.sta.comporium.net] has joined #code
23:04 Xires [xires@Nightstar-c54fd8cd.feedthetrolls.net] has quit [Ping timeout: 121 seconds]
23:04 Xires [xires@Nightstar-c54fd8cd.feedthetrolls.net] has joined #code
23:28
<&ToxicFrog>
<Vornicus> Der: I use global objects occasionally when I need to memoize a function. -- what
23:29
<~Vornicus>
TF: well I guess not global really, but module-wide.
23:29
<~Vornicus>
mostly because there seems no other sensible place to put them.
23:31
<~Vornicus>
this is python, function static doesn't exist except as a terrible misfeature.
23:35
<&ToxicFrog>
You can't have a @memoize decorator that returns a closure over the function being memoized?
23:35
<~Vornicus>
Sometimes I check the memoized stuff for more than just "is this in there"; doing for instance binomial coefficients half the values get mirrored onto others.
23:36
<~Vornicus>
And using the existing memo'd stuff if it exists can be a lot faster than doing them stright out.
23:39
<&McMartin>
TF: Python doesn't really do proper closures.
23:41
<~Vornicus>
There is however a memoize decorator in the standard library. It's just that sometimes I use a lot more interconnections between mathematical functions than would be allowed by such a thing.
23:41
<@Rhamphoryncus>
McMartin: for some definition of closure..
23:44
<@Rhamphoryncus>
ToxicFrog: a @memoize decorator is certainly possible. I'm not sure how a closure is involved though
23:44
< RichyB>
ToxicFrog: Yes, of course you can, just as you expect.
23:46
<&ToxicFrog>
Rhamphoryncus: the decorator needs to return a function f' that is the memoized form of f. f' needs to store f (and the memoization table) somewhere. The most convenient place is as an upvalue of f'.
23:47
<@Rhamphoryncus>
http://wiki.python.org/moin/PythonDecoratorLibrary#Alternate_memoize_as_nested_f unctions
23:47
<&ToxicFrog>
E.g. function memoize(f) local cache = {}; return function(...) .... cache[...] = f(...) .... return cache[...] end end
23:48
<@Rhamphoryncus>
What's an upvalue?
23:48
< RichyB>
Yes, you can cheerfully do that in Python.
23:48
<&McMartin>
Rhamphoryncus: A value that's in a higher lexical scope.
23:48
<@Rhamphoryncus>
ah
23:49
<@Rhamphoryncus>
So what you'd use a closure for
23:49
< RichyB>
"Python lacks closures" is an overly-strong statement. The thing that it notably lacks is the ability to modify upvars without having to manually specify "nonlocal x".
23:50
<@Rhamphoryncus>
RichyB: it also doesn't create a snapshot of upvars at the time the closure is created, instead storing a reference to the parent scope. This is significant if you create closures in a loop
23:51
<&McMartin>
That is, IIRC, a fairly common malady
23:51
< RichyB>
Neither does JavaScript.
23:51
< RichyB>
So, query. Would you say that Haskell lacks closures?
23:52
<@Rhamphoryncus>
I've seen enough people trip over it, including myself, that it's worth designing a better solution into a language
23:52
<@Rhamphoryncus>
(implicitly copying everything is not necessarily a better solution..)
23:52
<&McMartin>
That requires knowing what a deep copy involves, which you can't actually enforce in a non-purely-functional language
23:52
< RichyB>
What you are asking for is mutually incompatible with the desire to have mutable upvars.
23:54 thalass [thalass@Nightstar-23c59d3f.bigpond.net.au] has joined #code
23:54
<@Rhamphoryncus>
It is an ugly problem
23:55
<&McMartin>
http://arstechnica.com/information-technology/2013/02/step-back-in-time-with-the -elegant-source-code-for-photoshop-1-0/
23:55
< RichyB>
Hrmn. Haskell doesn't have the problem because if you're creating closures in a loop, well, your loop was a recursing function in the first place.
23:56
< RichyB>
JS's solution is AIUI (like the lifting of 'var' statements to the nearest function() scope) chosen specifically for performance concerns, because scoping was expensive in the first JS interpreter.
23:56 * Rhamphoryncus wonders if closures deserve their own syntax, with the default nested functions not seeing any upvars except globals
23:58
< RichyB>
That seems terrible too. If you had nested functions that don't have access to the enclosing scope, you would not allow them to be used, because all they're good for is hiding code objects from global scope. We have things like explicit export lists for that.
23:58
<@Rhamphoryncus>
Oww, good point
23:59 * RichyB dials down the harshometer on his phrasing for next time.
23:59
<@Rhamphoryncus>
Nah, wasn't harsh. Just painful to have missed something so obvious and significant
--- Log closed Fri Feb 15 00:00:09 2013
code logs -> 2013 -> Thu, 14 Feb 2013< code.20130213.log - code.20130215.log >

[ Latest log file ]