--- Log opened Mon Jul 18 00:00:58 2016 |
00:05 | | catadroid` [catadroid@Nightstar-q7md52.dab.02.net] has joined #code |
00:06 | | ion [Owner@Nightstar-6grqph.vs.shawcable.net] has quit [Ping timeout: 121 seconds] |
00:06 | | ion [Owner@Nightstar-6grqph.vs.shawcable.net] has joined #code |
00:06 | | mode/#code [+o ion] by ChanServ |
00:09 | | catadroid [catadroid@Nightstar-fc60e5.dab.02.net] has quit [Ping timeout: 121 seconds] |
00:09 | | ion_ [Owner@Nightstar-6grqph.vs.shawcable.net] has joined #code |
00:09 | | mode/#code [+o ion_] by ChanServ |
00:10 | | ion_ [Owner@Nightstar-6grqph.vs.shawcable.net] has quit [[NS] Quit: bye] |
00:30 | | ion [Owner@Nightstar-6grqph.vs.shawcable.net] has quit [Ping timeout: 121 seconds] |
00:33 | | ion [Owner@Nightstar-6grqph.vs.shawcable.net] has joined #code |
00:33 | | mode/#code [+o ion] by ChanServ |
00:40 | | ion [Owner@Nightstar-6grqph.vs.shawcable.net] has quit [Ping timeout: 121 seconds] |
00:43 | | ion [Owner@Nightstar-6grqph.vs.shawcable.net] has joined #code |
00:43 | | mode/#code [+o ion] by ChanServ |
00:49 | | Turaiel[Offline] is now known as Turaiel |
00:52 | | ion [Owner@Nightstar-6grqph.vs.shawcable.net] has quit [Ping timeout: 121 seconds] |
00:54 | | ion [Owner@Nightstar-6grqph.vs.shawcable.net] has joined #code |
00:54 | | mode/#code [+o ion] by ChanServ |
01:19 | | ion_ [Owner@Nightstar-6grqph.vs.shawcable.net] has joined #code |
01:19 | | mode/#code [+o ion_] by ChanServ |
01:21 | | ion [Owner@Nightstar-6grqph.vs.shawcable.net] has quit [Ping timeout: 121 seconds] |
01:40 | | ion_ [Owner@Nightstar-6grqph.vs.shawcable.net] has quit [Ping timeout: 121 seconds] |
01:43 | | ion [Owner@Nightstar-6grqph.vs.shawcable.net] has joined #code |
01:43 | | mode/#code [+o ion] by ChanServ |
02:07 | | crystalclaw is now known as crystalclaw|AFK |
02:10 | | ion [Owner@Nightstar-6grqph.vs.shawcable.net] has quit [Ping timeout: 121 seconds] |
02:10 | | himi [sjjf@Nightstar-dm0.2ni.203.150.IP] has joined #code |
02:10 | | mode/#code [+o himi] by ChanServ |
02:12 | | ion [Owner@Nightstar-6grqph.vs.shawcable.net] has joined #code |
02:12 | | mode/#code [+o ion] by ChanServ |
02:37 | | ion [Owner@Nightstar-6grqph.vs.shawcable.net] has quit [Ping timeout: 121 seconds] |
02:40 | | ion [Owner@Nightstar-6grqph.vs.shawcable.net] has joined #code |
02:40 | | mode/#code [+o ion] by ChanServ |
03:01 | | Vornotron [Vorn@ServerAdministrator.Nightstar.Net] has quit [Connection reset by peer] |
03:10 | | ion_ [Owner@Nightstar-6grqph.vs.shawcable.net] has joined #code |
03:10 | | mode/#code [+o ion_] by ChanServ |
03:13 | | ion [Owner@Nightstar-6grqph.vs.shawcable.net] has quit [Ping timeout: 121 seconds] |
03:41 | | ion_ [Owner@Nightstar-6grqph.vs.shawcable.net] has quit [Ping timeout: 121 seconds] |
03:43 | | ion [Owner@Nightstar-6grqph.vs.shawcable.net] has joined #code |
03:44 | | mode/#code [+o ion] by ChanServ |
03:53 | <&McMartin> | Man, Rust is so the anti-Clojure |
03:54 | <&McMartin> | I'm seeing catalyst excited as unstoppable power is hers, and meanwhile I'm accomplishing stuff in Rust with almost exactly the same sense of "Ha ha, the pieces fit together" as one gets for solving a SpaceChem or Factorio level |
03:57 | <&Derakon> | What are you doing in order to learn the language? What is your project(s)? |
03:58 | <&McMartin> | I'd written about half a BASIC compiler in Scheme awhile ago, and I'm translating it to Rust and making it more idiomatic as I go. |
03:58 | <&Derakon> | Ah ha. |
03:58 | <&McMartin> | As Rust is notionally multiparadigm this does mean making use of higher-order functions and traits and all that good stuff |
03:58 | <&Derakon> | I guess my equivalent go-to project would probably be a map generator or something. |
03:58 | <&McMartin> | The Scheme project collapsed under its own weight years ago because Scheme's data abstraction layer is too manual |
03:58 | <&McMartin> | I'd basically abandoned it on the grounds that this project needed an ML-like |
04:08 | | Shady [ShadyGuru@Nightstar-8v9css.leh.ptd.net] has quit [[NS] Quit: Yay, he's gone] |
04:09 | | Turaiel is now known as Turaiel[Offline] |
04:10 | | ion_ [Owner@Nightstar-6grqph.vs.shawcable.net] has joined #code |
04:10 | | mode/#code [+o ion_] by ChanServ |
04:12 | | ion [Owner@Nightstar-6grqph.vs.shawcable.net] has quit [Ping timeout: 121 seconds] |
04:13 | | ion_ [Owner@Nightstar-6grqph.vs.shawcable.net] has quit [[NS] Quit: Reconnecting] |
04:13 | | ion [Owner@Nightstar-6grqph.vs.shawcable.net] has joined #code |
04:13 | | mode/#code [+o ion] by ChanServ |
04:32 | | ion_ [Owner@Nightstar-6grqph.vs.shawcable.net] has joined #code |
04:32 | | mode/#code [+o ion_] by ChanServ |
04:34 | | ion [Owner@Nightstar-6grqph.vs.shawcable.net] has quit [Ping timeout: 121 seconds] |
04:39 | | Shady [ShadyGuru@Nightstar-8v9css.leh.ptd.net] has joined #code |
04:42 | | VirusJTG [VirusJTG@Nightstar-6i5vf7.sta.comporium.net] has quit [Connection closed] |
04:43 | | Shady [ShadyGuru@Nightstar-8v9css.leh.ptd.net] has quit [[NS] Quit: Yay, he's gone] |
04:52 | | ion_ [Owner@Nightstar-6grqph.vs.shawcable.net] has quit [Ping timeout: 121 seconds] |
04:53 | <&Derakon> | T-2. |
04:54 | | ion [Owner@Nightstar-6grqph.vs.shawcable.net] has joined #code |
04:54 | | mode/#code [+o ion] by ChanServ |
04:55 | | crystalclaw|AFK is now known as crystalclaw |
04:58 | | Derakon is now known as Derakon[AFK] |
05:08 | | Shady [ShadyGuru@Nightstar-8v9css.leh.ptd.net] has joined #code |
05:52 | | crystalclaw is now known as crystalclaw|AFK |
06:08 | <&McMartin> | It pleases me that the rust internals doc still opens with "Due to the nature of this problem, it may lead to unleashing untold horrors that shatter your psyche into a billion infinitesimal fragments of despair." |
06:30 | | Shady [ShadyGuru@Nightstar-8v9css.leh.ptd.net] has quit [[NS] Quit: Yay, he's gone] |
06:35 | | catadroid [catadroid@Nightstar-bk1mgm.dab.02.net] has joined #code |
06:38 | | catadroid` [catadroid@Nightstar-q7md52.dab.02.net] has quit [Ping timeout: 121 seconds] |
07:41 | | celticminstrel is now known as celmin|sleep |
08:04 | < catadroid> | I've officially contributed to open source software! |
08:04 | < catadroid> | I reported a bug and it got fixed |
08:09 | | himi [sjjf@Nightstar-dm0.2ni.203.150.IP] has quit [Ping timeout: 121 seconds] |
08:22 | | Turaiel[Offline] [Brandon@Nightstar-7mqsi0.mi.comcast.net] has quit [[NS] Quit: Bouncer terminated] |
08:39 | <@Alek> | yay! |
09:04 | | Kindamoody[zZz] is now known as Kindamoody |
09:25 | < catadroid> | ...and now that clojure has convinced me that maps and vectors are logically functions, I wish they were callable in other languages |
09:53 | | macdjord [macdjord@Nightstar-r9vt2h.mc.videotron.ca] has joined #code |
09:53 | | mode/#code [+o macdjord] by ChanServ |
10:06 | | ion_ [Owner@Nightstar-6grqph.vs.shawcable.net] has joined #code |
10:06 | | mode/#code [+o ion_] by ChanServ |
10:07 | | ion [Owner@Nightstar-6grqph.vs.shawcable.net] has quit [Ping timeout: 121 seconds] |
10:09 | | ion [Owner@Nightstar-6grqph.vs.shawcable.net] has joined #code |
10:09 | | mode/#code [+o ion] by ChanServ |
10:12 | | ion [Owner@Nightstar-6grqph.vs.shawcable.net] has quit [[NS] Quit: bye] |
10:13 | | ion_ [Owner@Nightstar-6grqph.vs.shawcable.net] has quit [Ping timeout: 121 seconds] |
10:13 | | ion [Owner@Nightstar-6grqph.vs.shawcable.net] has joined #code |
10:13 | | mode/#code [+o ion] by ChanServ |
10:27 | | himi [sjjf@Nightstar-v37cpe.internode.on.net] has joined #code |
10:27 | | mode/#code [+o himi] by ChanServ |
10:51 | | ion_ [Owner@Nightstar-6grqph.vs.shawcable.net] has joined #code |
10:51 | | mode/#code [+o ion_] by ChanServ |
10:54 | | ion [Owner@Nightstar-6grqph.vs.shawcable.net] has quit [Ping timeout: 121 seconds] |
11:02 | | VirusJTG [VirusJTG@Nightstar-055.kas.104.208.IP] has joined #code |
11:02 | | mode/#code [+ao VirusJTG VirusJTG] by ChanServ |
11:17 | | ion_ [Owner@Nightstar-6grqph.vs.shawcable.net] has quit [Ping timeout: 121 seconds] |
11:20 | | ion [Owner@Nightstar-6grqph.vs.shawcable.net] has joined #code |
11:20 | | mode/#code [+o ion] by ChanServ |
11:40 | | Vornicus [Vorn@ServerAdministrator.Nightstar.Net] has joined #code |
11:40 | | mode/#code [+qo Vornicus Vornicus] by ChanServ |
11:54 | | ion [Owner@Nightstar-6grqph.vs.shawcable.net] has quit [Ping timeout: 121 seconds] |
11:57 | | ion [Owner@Nightstar-6grqph.vs.shawcable.net] has joined #code |
11:57 | | mode/#code [+o ion] by ChanServ |
12:02 | | Turaiel[Offline] [Brandon@Nightstar-7mqsi0.mi.comcast.net] has joined #code |
12:02 | | mode/#code [+o Turaiel[Offline]] by ChanServ |
12:15 | | ion [Owner@Nightstar-6grqph.vs.shawcable.net] has quit [Ping timeout: 121 seconds] |
12:18 | | ion [Owner@Nightstar-6grqph.vs.shawcable.net] has joined #code |
12:18 | | mode/#code [+o ion] by ChanServ |
12:25 | | ion [Owner@Nightstar-6grqph.vs.shawcable.net] has quit [Ping timeout: 121 seconds] |
12:28 | | ion [Owner@Nightstar-6grqph.vs.shawcable.net] has joined #code |
12:28 | | mode/#code [+o ion] by ChanServ |
12:50 | | Kindamoody is now known as Kindamoody|afk |
12:57 | | mac [macdjord@Nightstar-r9vt2h.mc.videotron.ca] has joined #code |
12:57 | | mode/#code [+o mac] by ChanServ |
12:59 | | macdjord [macdjord@Nightstar-r9vt2h.mc.videotron.ca] has quit [Ping timeout: 121 seconds] |
13:04 | <@Azash> | "you have to finish this today and push it to review" |
13:04 | <@Azash> | "sure, no problem" |
13:04 | <@Azash> | <30 minutes pass> |
13:04 | <@Azash> | <SCM goes down> |
13:05 | <@TheWatcher> | Naturally. |
13:05 | | catadroid` [catadroid@Nightstar-m7ucm1.dab.02.net] has joined #code |
13:08 | | catadroid [catadroid@Nightstar-bk1mgm.dab.02.net] has quit [Ping timeout: 121 seconds] |
13:50 | | celmin|sleep is now known as celticminstrel |
14:11 | | catadroid` [catadroid@Nightstar-m7ucm1.dab.02.net] has quit [[NS] Quit: Bye] |
14:11 | | catadroid [catadroid@Nightstar-m7ucm1.dab.02.net] has joined #code |
14:11 | | Netsplit Golgafrincham.Nightstar.Net <-> Krikkit.Nightstar.Net quits: @PinkFreud |
14:24 | | ErikMesoy [Erik@Nightstar-hq72t5.customer.cdi.no] has left #code [] |
15:00 | | Netsplit over, joins: @PinkFreud |
15:01 | | kourbou|afk [uid114955@Nightstar-u0buu4.irccloud.com] has joined #code |
15:02 | | kourbou|afk is now known as kourbou |
15:33 | | ErikMesoy [Erik@Nightstar-hq72t5.customer.cdi.no] has joined #code |
15:33 | | mode/#code [+o ErikMesoy] by ChanServ |
16:56 | | Shady [ShadyGuru@Nightstar-8v9css.leh.ptd.net] has joined #code |
16:58 | | ErikMesoy [Erik@Nightstar-hq72t5.customer.cdi.no] has quit [Ping timeout: 121 seconds] |
17:09 | | ErikMesoy [Erik@Nightstar-hq72t5.customer.cdi.no] has joined #code |
17:09 | | mode/#code [+o ErikMesoy] by ChanServ |
17:09 | | crystalclaw|AFK is now known as crystalclaw |
17:56 | | catalyst [catalyst@Nightstar-bt5k4h.81.in-addr.arpa] has joined #code |
19:10 | | catadroid [catadroid@Nightstar-m7ucm1.dab.02.net] has quit [[NS] Quit: Bye] |
19:20 | <@Alek> | hmm. how java treats variables as local vs global is much like how I was trying to figure out how to make variables work in python. never did figure it out... |
19:20 | <@Alek> | didn't get far enough I guess. |
19:26 | <&McMartin> | When you say "global" do you mean static or as instance variables? |
19:26 | | * McMartin would generally divide Java's variables up into those three categories |
19:27 | <@Alek> | I mean as variables defined in the top level of the program, but accessible in all functions nested inside. as opposed to local, which are defined and accessible only inside a given function. |
19:28 | | * Alek eyebrows at conditional function defining. forbidden, but if platforms actually supported it consistently, it could be a pretty versatile tool. |
19:29 | <@Alek> | oh. I should clarify. javascript, not java. -_- |
19:29 | <@Alek> | too easy to shorten it. >_< |
19:29 | <~Vornicus> | only slightly different |
19:32 | <&McMartin> | Wait, since when is conditional fn defining forbidden in JS, JS has first-class functins |
19:32 | <&McMartin> | What's stopping you from doing if (...) x = function() { ... } else x = function() { ... } |
19:33 | <&McMartin> | (Or for that matter, else x=3, because dynamic typing wheeegonk) |
19:34 | <@Alek> | function declarations being allowed at any point in the program but callable before they're declared is a fun quirk, but probably the main reason conditional defining is forbidden. |
19:34 | < ToxicFrog> | Alek: python is weird⢠here because it uses function scope, not lexical block scope |
19:35 | < ToxicFrog> | ...but it's not forbidden, as McM just pointed out. |
19:35 | <@Alek> | TF: yeah, I gathered. |
19:35 | <@Alek> | What happens when you put such a function definition inside a conditional (if) block or a loop? Well, donât do that. Different JavaScript platforms in different browsers have traditionally done different things in that situation, and the latest standard actually forbids it. If you want your programs to behave consistently, only use this form of function-defining statements in the outermost |
19:35 | <@Alek> | block of a function or program. |
19:35 | <@Alek> | function example() { |
19:35 | <@Alek> | function a() {} // Okay |
19:35 | <@Alek> | if (something) { |
19:35 | <@Alek> | function b() {} // Danger! |
19:35 | <@Alek> | } |
19:35 | <@Alek> | } |
19:35 | <&McMartin> | Oh! |
19:35 | <&McMartin> | Yeah |
19:35 | <&McMartin> | I was using a different syntax involving function "literals" |
19:35 | <&McMartin> | That actually changes the meaning |
19:36 | < ToxicFrog> | Oh. Yeah, but "function b() {}" is a sugar for "var b = function() {}", and the latter is legal. |
19:36 | < ToxicFrog> | (...right? JS doesn't do something wacky with 'function foo' vs 'foo = function'?) |
19:36 | <&McMartin> | It might |
19:36 | < ToxicFrog> | (I mean, apart from the parser wackiness we're looking at right now?)( |
19:36 | <@Alek> | not really, other than I just said function x() can be defined after x() is called. |
19:36 | <&McMartin> | Most of JS's function semantics are stolen from Scheme, and Scheme's internal (define) functions are different from let |
19:37 | <&McMartin> | So that's dangerous, yes |
19:37 | <&McMartin> | My guess is that the code Alek quoted would try to call b before the if and get a null, or close over uninitialized variables or something |
19:38 | <&McMartin> | JS's unique design error here is that variable declarations are shifted up to the top of the function they're defined in, which nobody else does because it secretly introduces errors where you use a variable before it has actually gotten the value it should have, or it gets its new value early |
19:41 | < ToxicFrog> | s/nobody else/nobody else except python/? |
19:42 | <@ErikMesoy> | all of my what |
19:46 | | Shady [ShadyGuru@Nightstar-8v9css.leh.ptd.net] has quit [[NS] Quit: Yay, he's gone] |
19:46 | | kourbou [uid114955@Nightstar-u0buu4.irccloud.com] has quit [[NS] Quit: Connection closed for inactivity] |
19:47 | <&McMartin> | ToxicFrog: Python, last I checked, doesn't declare variables at all; they spring into existence on first write. |
19:48 | <&McMartin> | Does Py3 change this? |
19:48 | <&McMartin> | JS and Python do *not* have the same variable semantics. |
19:48 | <@Pi> | McMartin: It's more accurate to say that assignment is declaration. |
19:49 | <@Pi> | McMartin: It still works like a static declaration at the start of whichever lexical scope the assignment appears in. |
19:49 | <@Pi> | (Same way as in e.g. Scheme and similar languages) |
19:49 | <&McMartin> | My test over here disagrees |
19:49 | <&McMartin> | def f(): a = b+3; b = 2; return a |
19:49 | <&McMartin> | f() -> UnboundLocalError |
19:50 | <@Pi> | Right. b is implicitly declared at the start of that local scope, but you get UnboundLocalError when you try to read it before it's been given its initial value. |
19:51 | <&McMartin> | Oh, this is in the presence of shadowed globals? |
19:51 | <&McMartin> | Right, OK |
19:51 | <@Pi> | If Python had a hypothetical "local" keyword to declare bindings without assignment, the above would be: def f() local a; local b; a = b+3; b = 2; return a |
19:51 | <&McMartin> | Right, and more to the point |
19:52 | <&McMartin> | def f(): a = b+3; return a |
19:52 | <@Pi> | Any assignment anywhere in a lexical context basically "declares" the local variable in that scope. |
19:52 | <&McMartin> | if you have a global b, *that* f() works, but the first one still says unbound local. |
19:52 | <@Pi> | Righ,t because the other one declares b to be local. |
19:52 | < ToxicFrog> | McMartin: yes. Assigning to a variable anywhere in a function (without explicitly declaring it global) declares that variable for the entire scope of the function, including the parts that precede the first assignment. |
19:53 | < ToxicFrog> | Which is what I thought you meant by "variable declarations are shifted to the top of the function they're defined in". |
19:53 | <&McMartin> | ToxicFrog: OK, so, my vague memory of JS was that it moved not merely the declaration but the initialization up tot he top. |
19:53 | <&McMartin> | And that this could introduce use-before-def errors invisible in the code. |
19:53 | <@Pi> | McMartin: Consider this: |
19:53 | < ToxicFrog> | (and it is function, not block; assign to a variable inside an if or a for block and it's declared for the entire containing function) |
19:53 | <@Pi> | b = 10; def f(): return b |
19:53 | < ToxicFrog> | Aah. |
19:53 | <@Pi> | >>> f() |
19:53 | <@Pi> | 10 |
19:54 | <@Pi> | But: |
19:54 | <&McMartin> | Pi: Yep, that's exactly the case I was trying to describe before re: shadowing |
19:54 | <@Pi> | b = 10; def f(): return b; if False: b = 10 |
19:54 | <@Pi> | >>> f() |
19:54 | <@Pi> | UnboundLocalError |
19:54 | < ToxicFrog> | I thought by "introduces errors where you read a variable before it's assigned to" you meant something akin to python's UnboundLocalError |
19:54 | <@Pi> | It doesn't matter where the assignment occurs; even if it's in dead / unreachable code. |
19:54 | <&McMartin> | Yeah, I meant more like "if you list your field initializers in the wrong order in a C++ constructor" |
19:54 | <@Pi> | Statically and syntactically, it causes b to be local. |
19:55 | <&McMartin> | Pi: Right. I appear to have this rule internalized as "read-only global references are imported silently if unambiguous" |
19:55 | <@Pi> | (unless you override it with the global or nonlocal keywords, to make b refer to the outer b instead, including assignments) |
19:55 | | * Alek headaches. |
19:55 | <&McMartin> | Alek: We're in language pedantry land over here, don't mind us much |
19:55 | <@Alek> | :P |
19:55 | <&McMartin> | Your only real takeaway here should be "actually, there's a stock 'right answer' for this, which neither JS nor Python do" |
19:56 | <@Pi> | McMartin: Well, the only real rule is "assignment implicitly declares a new local variable as part of the current scope" |
19:56 | <@Pi> | (unless overriden with global/nonlocal, again) |
19:57 | <@Alek> | I got as far in python as figuring that the best way (other than saving to file) to pass variables between functions was to save them to a huge array that would be passed into and out of every single function that wants to use any of the variables. |
19:58 | <&McMartin> | Anything that is a "container", really; for structured data the preferred result would be one of a set of objects as opposed to one huge array |
19:58 | <@ErikMesoy> | Alek: I use a dummy object with lots of attached variables. |
19:58 | <@Pi> | Specifically, the scope resolution in Python is always completely static: it never changes or depends on anything at runtime. When the code is compiled, each lexical block is statically initialized with a list of local variables. |
19:59 | < ToxicFrog> | Alek: ...as opposed to just passing them to the function? |
19:59 | <&McMartin> | Alek: That's A Problem, but if your head is hurting here, I'll just say that this rule exists to prevent the Things from the Dungeon Dimensions getting out |
19:59 | <&McMartin> | ToxicFrog: As opposed to taking references to stack variables |
19:59 | < ToxicFrog> | Oh. |
19:59 | < ToxicFrog> | Yes, that makes more sense. |
19:59 | <@ErikMesoy> | varholder = Object(); varholder.a, varholder.b, varholder.a_flag |
20:00 | <&McMartin> | (Java has ended up needing very similar tricks now that it has lambdas with value-only scoping rules) |
20:01 | <&McMartin> | (Declare a length one array as a constant array, and while that array is constant and may have its reference passed by value, the contents are still mutable, so you can use it as a communications channel) |
20:03 | <&McMartin> | And I think JS is going to be similar, but you're more likely to use a dict to pass state around |
20:05 | <@ErikMesoy> | Pi: I'm not getting that UnboundLocalError you described on b. Can you pastebin? |
20:06 | <@Pi> | ErikMesoy: That's verbatim |
20:06 | <@Pi> | def f(): return b; if False: b=10 ? |
20:07 | <@ErikMesoy> | aha. I did not have the if-clause indented inside the function. now I get it. |
20:07 | <@Pi> | The if False is optional, really; the assignment can appear absolutely anywhere, as long as it's the same scope. |
20:08 | <@Pi> | For example, here's another Python 2 only version of the same thing: |
20:08 | <@Pi> | def f(): return b; [None for b in []] |
20:08 | <@ErikMesoy> | ok that's weird |
20:09 | <@ErikMesoy> | note to self: do not mess with variables after returning them |
20:09 | <@Pi> | In Python 2, list comprehensions share their containing scope, unlike list(<genexp>) |
20:09 | <@Pi> | Mainly for historical reasons. |
20:10 | <@Pi> | So the presence of the above list comprehension counts as a syntactic assignment to b, even though no assignment can actually happen at runtime. |
20:10 | <@Pi> | (In Python 3, list comprehension is effectively syntax sugar for list(<genexp>), which creates a new scope, so it no longer acts as an assignment in the containing scope like in Python 2) |
20:11 | <@Pi> | (So with Python 3, "def f(): return b; [None for b in []]" does not give the UnboundLocalError, and lets b resolve to the outer scope instead.) |
20:12 | <&McMartin> | (And thus probably gives NameError instead) |
20:13 | <&McMartin> | But yeah, these rules cause the most friction, I think, because there are two sets of semantics for declarations in practice, and for one the best practice is "declare everything at the top" and for the other the best practice is "declare at the last possible moment" |
20:13 | <&McMartin> | In C++ you can sort of claim a new scope begins with every statement |
20:17 | <&McMartin> | ... no, that's too course-grained |
20:17 | <&McMartin> | *coarse |
20:17 | <&McMartin> | After every declaration, top to bottom, left to right. That way destruction order gets determined consistently |
20:21 | | Shady [ShadyGuru@Nightstar-8v9css.leh.ptd.net] has joined #code |
20:21 | <&McMartin> | Yep |
20:21 | | * McMartin confirms that C++ works the way he expected |
20:22 | <&McMartin> | int x = 3; int main(int, char**) { cout << x << endl; /* 3 */ int x = 4; cout << x << endl; /* 4 */ return 0; } |
20:27 | <@Alek> | I was thinking in terms of game programming. I started with a small pseudo zorklike - but how to store inventory, flags, etc? |
20:28 | | Shady [ShadyGuru@Nightstar-8v9css.leh.ptd.net] has quit [[NS] Quit: Yay, he's gone] |
20:28 | <@Alek> | and I was passing a whole huge array because functions would be calling other functions and different functions would call the same one, so easier to pass everything at once than figure out what would be called when. |
20:29 | <@Alek> | or wanted to pass an array, anyway. didn't get as far as figuring out how to /save/ arrays in the first place. :P |
20:29 | <@Alek> | *shrugs* |
20:29 | <@Alek> | later. right now I'm on JS. |
20:34 | < ToxicFrog> | For that you'd probably have eventually ended up with a dict and/or object holding the game state and passing that around. |
20:44 | | kourbou [uid114955@Nightstar-u0buu4.irccloud.com] has joined #code |
20:57 | | kourbou [uid114955@Nightstar-u0buu4.irccloud.com] has quit [[NS] Quit: ] |
21:06 | | kourbou [uid114955@Nightstar-u0buu4.irccloud.com] has joined #code |
21:17 | <@celticminstrel> | I'm getting a segfault in glCreateShader. |
21:18 | <@celticminstrel> | How am I supposed to deal with such a thing. |
21:18 | | * celticminstrel is using SDL2 here as well, for reference. |
21:18 | | * celticminstrel doubt it's relevant but just in case. |
21:23 | <@celticminstrel> | Oh, right, I think I get it. |
21:23 | <@celticminstrel> | Hmm. |
21:26 | <@celticminstrel> | Got it, but this still isn't drawing anything. :( |
21:27 | <@celticminstrel> | Right now all I'm trying to do is draw a rectangle with a VAO... |
22:42 | | macdjord [macdjord@Nightstar-r9vt2h.mc.videotron.ca] has joined #code |
22:42 | | mode/#code [+o macdjord] by ChanServ |
22:43 | | mac [macdjord@Nightstar-r9vt2h.mc.videotron.ca] has quit [Ping timeout: 121 seconds] |
23:02 | | Kindamoody|afk is now known as Kindamoody |
23:21 | <@celticminstrel> | Okay, so it works if I don't request a 3.2 context, so I guess for now I won't do that. |
23:21 | <@celticminstrel> | Although I don't really understand what my coordinates mean. |
23:22 | | himi [sjjf@Nightstar-v37cpe.internode.on.net] has quit [Ping timeout: 121 seconds] |
--- Log closed Tue Jul 19 00:00:14 2016 |