←2018-05-29 2018-05-30 2018-05-31→ ↑2018 ↑all
00:04:42 -!- zemhill___ has joined.
00:05:19 -!- ocharles has quit (Ping timeout: 265 seconds).
00:05:20 -!- zemhill__ has quit (Ping timeout: 265 seconds).
00:05:45 -!- ocharles_ has joined.
00:05:48 -!- Lord_of_Life has quit (Ping timeout: 265 seconds).
00:05:48 -!- fungot has quit (Ping timeout: 265 seconds).
00:06:04 -!- fungot has joined.
00:13:58 -!- Lord_of_Life has joined.
00:38:02 -!- copumpkin has quit (Ping timeout: 269 seconds).
00:38:13 -!- ProofTechnique[m has quit (Ping timeout: 256 seconds).
01:00:32 -!- ProofTechnique[m has joined.
01:07:35 -!- Sgeo_ has joined.
01:10:21 -!- Sgeo has quit (Ping timeout: 240 seconds).
01:16:41 -!- copumpkin has joined.
01:23:09 -!- boily has quit (Quit: OPAL CHICKEN).
01:45:35 <shachaf> Is there a language where, you can write "{ X; ... }" and have it turn into "{ Y; ...; Z; }", where Z is some end code for Y?
01:46:01 <shachaf> This isn't quite like e.g. C++ destructors because the code wouldn't be executed at early exit.
01:47:40 <ais523> shachaf: hmm, weird, several languages have something like that but it's normally specifically to make the early-exit case work
01:48:01 <ais523> so if you want to exclude it, it might be hard to find a language which supports that exclusion
01:48:13 <ais523> D has a range of operators like that but I'm not sure if any have the exact semantics you want
01:48:37 <ais523> there are some languages flexible enough to do just about anything, e.g. Perl would let you dynamically change the parser so that it slipped in a Z before the }
01:48:46 <ais523> but I don't think that's what you're looking for either
01:50:25 <shachaf> ais523: I might want something that supports different behavior for early and non-early exit.
01:51:33 <ais523> I guess this is the point where I ask what you're trying to do in more general terms :-D
01:51:35 <shachaf> But really the early-exit case is well explored, so I'm wondering whether anything handles this behavior.
01:53:02 <shachaf> I wonder what the best way to describe it is.
01:53:40 <ais523> I'm reminded of the way you can put an "else" on a loop in Python
01:53:45 <ais523> this isn't the same at all but it seems similar in a way
01:53:52 <shachaf> Yes, I was thinking about that.
01:54:43 <ais523> you could probably do something with the condition of a for-loop
01:55:03 <shachaf> Hmm, maybe. But I also want to be able to goto Z or something.
01:55:03 <ais523> if you had a do-for loop and made it evaluate to false, it'd have the exact semantics you wanted
01:55:18 <ais523> (surely there's got to be a language with a do-for loop?)
01:55:33 <shachaf> So one thing I was thinking about was how in a lot of languages, say Ruby, you write things like "open(filename) {|f| ... }"
01:55:50 <shachaf> Where "open" takes a function argument and takes care of the cleanup and so on.
01:55:51 <ais523> I thought https://esolangs.org/wiki/TMMLPTEALPAITAFNFAL might sometimes have one, but apparently not
01:56:15 <ais523> shachaf: right, I think all serious languages are moving in that direction
01:56:21 <ais523> or, well, maybe not /all/ of them
01:56:23 <ais523> but a lot of major ones
01:56:24 <shachaf> Whereas in C++ RAII-style, you just write "{ File f = open(...); ... }", and f is automatically closed at the end of the scope.
01:56:52 <ais523> even Java has "try (InputStream f = new FileInputStream(…)) {…}"
01:57:02 <shachaf> In a lot of ways the C++ way is nicer -- e.g. you don't end up with deeply-nested scopes and lots of lambdas if you have a lot of these things. And also some other things.
01:57:11 <ais523> (I think "try" is a case of reusing a keyword to avoid accidentaly invalidating old variable names)
01:57:24 <shachaf> So I was wondering whether you can make all control flow use this mechanism.
01:57:28 <ais523> I see RAII as similar
01:57:45 <shachaf> For example write { if(p); ... } to mean "if (p) { ... }"
01:57:58 <ais523> oh, you definitely /can/ do that in D
01:57:59 <shachaf> Where the if executes the rest of the block only if its argument is true.
01:58:01 <ais523> but maybe only at the function level
01:58:08 <ais523> actually you can even do that in Perl
01:58:12 <ais523> { last unless p; … }
01:58:24 <ais523> (where "last" jumps out of the current block)
01:58:30 <shachaf> Well, I don't just want it for if, I want it for everything.
01:58:42 <ais523> yes, if is easiest
01:58:54 <ais523> the other cases, e.g. while, are suspiciously similar to come from
01:59:06 <shachaf> { while(p); ... }, { repeat(5); repeat(3); ... }, etc.
01:59:25 <shachaf> There were some other things I wanted that are less related to this.
01:59:26 -!- tromp_ has quit (Remote host closed the connection).
01:59:42 <shachaf> You might be able to write { x = for_in(arr); ...x... } to iterate an array
02:01:06 <shachaf> And then all these things can be implemented in terms of conditional goto or something.
02:01:47 <shachaf> There are a lot of nice things you can get if you can make it work.
02:03:34 <ais523> if you don't mind early exits continuing the loop, then you could use a cross between destructors and continuations
02:03:46 <ais523> perhaps the equivalent of breaking from a loop would be leaking the object
02:03:54 <shachaf> I want to support both break and continue.
02:03:56 <ais523> (Rust has an explicit function for leaking objects)
02:04:12 <shachaf> This is very continuationy, of course.
02:04:35 <shachaf> It's kind of like in { X; ... }, X gets the ... as an argument, CPS.
02:04:43 <ais523> hmm, Tableaux's @n syntax is basically "put the rest of the code into a block" in effect
02:04:48 <ais523> although it wasn't intended as that at all
02:04:52 <shachaf> (This use use of the acronym isn't standard.)
02:04:59 <ais523> come to think of it, this is basically Python one-liners
02:05:54 <shachaf> Anyway I don't really want it to be implemented in terms of complicated things like lambdas if possible.
02:06:16 <ais523> right, I guess what we want here is sugar for a "consuming block"
02:06:24 <shachaf> This is in the end pretty similar to the generated assembly you get for all these constructs.
02:06:31 <ais523> Lispers often use ] to represent "do ) for the rest of the program", so [ would work as a mirror of that
02:06:35 <shachaf> So I want a straightforward translation to low-level code.
02:07:11 <shachaf> There are also questions of how you represent if-else and switch and so on. I have some ideas that end up being pretty lisp-like.
02:07:29 <ais523> right, I'm mentally thinking about this as sugar for Lisp more than anything else
02:07:30 <shachaf> I'm not sure what you mean by [
02:08:01 -!- moei has quit (Ping timeout: 248 seconds).
02:08:06 <shachaf> I was thinking of an indentation-sensitive syntax where if you write { to open a block and then you unindent to some level, you automatically get }s inserted to match the level.
02:08:28 <shachaf> Then what you would get with this syntax looks more or less like Python.
02:08:44 <ais523> basically, } means "close one block, then close an additional block for each [ since the previous { or }"
02:09:21 <ais523> if you're doing this as indentation-sensitive, then it's basically a normal indentation-sensitive language with a minimum indentation of 0 (rather than 1 like most of these languages use
02:09:24 <ais523> if a:
02:09:26 <ais523> x;
02:09:28 <ais523> if b:
02:09:31 <ais523> y;
02:09:32 <ais523> z;
02:09:56 <ais523> an easy way to stop if/else chains running to the right :-D
02:09:58 -!- moei has joined.
02:10:07 <shachaf> I guess that's true.
02:10:17 <ais523> most langauges have an elseif or the like specifically to optimize that case indentation-wise
02:10:22 <ais523> in this langauge you wouldn't need it
02:10:29 <shachaf> I think indentation-sensitive languages should generally have a non-indentation-sensitive syntax option, like Haskell.
02:10:46 <shachaf> How are you thinking "else" would be implemented?
02:10:54 <shachaf> I had some ideas but they were a little awkward.
02:11:23 <ais523> it'd require the matching if to have an indented (or same-line) block, otherwise you'd effectively have an else at the start of a block
02:11:26 <ais523> if a:
02:11:28 <ais523> x;
02:11:30 <ais523> else:
02:11:31 <ais523> y;
02:11:50 <shachaf> I don't want if-else to be keywords, though, just regular user-implemented things.
02:12:06 <shachaf> Ideally not even macros, just functions.
02:13:06 <shachaf> Assuming you have this one mechanism to insert code/variables at the end of a scope, and conditional goto, and appropriate labels for the beginning/end, you should be able to implement all the standard control flow in user code.
02:13:29 <shachaf> Though it gets kind of complicated, I think maybe you need five different labels for what I was thinking of.
02:13:40 <ais523> it's remarkably hard to do a nicely sugared else with conditional goto
02:13:47 <shachaf> ("start", "upkeep", "end", "cleanup"
02:13:53 <ais523> of course you can do it, but you need something like a stack of else addresses
02:14:18 <shachaf> You could do something lisp-style: { cond; { if(x); ... }; { else; ... }; }
02:14:18 <ais523> if you name them all individually it's easy, but people normally rely on the natural nesting of if/else
02:14:30 <shachaf> Where each if/else just needs to refer to the block immediately above.
02:15:26 <shachaf> Maybe that's what you meant by "a stack of else addresses".
02:20:55 <shachaf> Also if you have "return values" like { x := for(a); ... }, that's a little tricky
02:21:09 <shachaf> I guess it's a bit SSAy, which is similar to being a bit CPSy.
02:23:43 <shachaf> Anyway there are a lot of things that would be simplified with this model.
02:24:08 <shachaf> Things like nested loops or other control flow, of course.
02:24:55 <shachaf> But also initializers, like Go's "if x := y; z { ... }", which just turns into "{ x := y; if(z); ... }", or the initializer of a for loop.
02:25:24 -!- Warrigal has joined.
02:25:38 <Warrigal> Yo.
02:25:47 <Warrigal> Nut'n much, I'm just trying to figure out how to prove that 0 + x = x.
02:26:08 <shachaf> http://inutile.club/estatis/falso/ hth
02:27:23 <shachaf> Anyway there are a bunch of other things you can do if you use the model of "things inside blocks describe the block they're in" for everything, and allow flexible enough macros or something.
02:28:28 <shachaf> Maybe you can define functions as { (int x, char y) := args(); }, where args is a thing that interprets your calling convention.
02:29:35 <Warrigal> Are you... talking to me?
02:29:44 -!- Warrigal has changed nick to tswett.
02:30:01 <shachaf> Or maybe even { fun(f); (int x, char y) := args(); }. Which can get compiled to something like ".globl f; f: mov $rdi, ...; whatever"
02:30:39 <shachaf> So it's like a high-level thing with a pretty direct translation to assembly in terms of labels and (conditional) goto.
02:31:02 <shachaf> Maybe lambdas can specify their captures this way too, I don't know.
02:31:30 <tswett> Something tells me you're not talking to me.
02:31:40 <shachaf> tswett: The link was for you.
02:31:49 <tswett> *nod*
02:31:55 <shachaf> That's as much as I can help without more context.
02:32:37 <shachaf> Also you changed your nick and I have no nick permanence so I forgot you existed.
02:32:47 <tswett> *nod nod*
02:33:28 <tswett> Yeah, so, I'm trying to prove that 0 + x = x.
02:33:40 <tswett> The main axiom I've got is...
02:33:59 <tswett> + is the unique binary operator on natural numbers such that p + 0 = p and p + S(x) = S(p + x).
02:34:58 <tswett> There's no axiom allowing proofs by induction.
02:35:19 <shachaf> then it seems p. tricky hth
02:35:33 <tswett> Yeah, I'm definitely not sure that what I'm trying to do is possible to do.
02:35:48 <tswett> Now, it's pretty trivial that 0 + 0 = 0.
02:36:10 <tswett> And, of course, we have 0 + S(x) = S(0 + x).
02:37:29 <tswett> It probably wouldn't be too much of a stretch to say that, for any particular number y, if 0 + y = y, then 0 + S(y) = S(y).
02:40:40 <tswett> Lemme abstract a little. I have a function f such that f(0) = 0 and f(S(x)) = S(f(x)).
02:41:34 <tswett> Oh, there we go. Uniqueness of inductively defined functions.
02:43:00 <tswett> It's an axiom schema which has an instance which says: "There is exactly one function f such that f(0) = 0 and f(S(x)) = S(f(x))."
02:43:12 <tswett> Since 0 + x satisfies those equations, and x also satisfies those equations, 0 + x = x.
02:44:59 <shachaf> can you translate that to categories twh
02:45:52 <tswett> Uhhhh, sure.
02:46:20 <tswett> So we've got an arrow plus : N * N -> N.
02:46:31 <tswett> And arrows zero : 1 -> N and succ : N -> N.
02:47:24 <tswett> Ummmm, what's the next thing.
02:48:00 <shachaf> Is this a natural numbers object or what?
02:48:04 <tswett> Yes.
02:48:52 <tswett> So, consider the arrows const_zero : N -> N and id_N : N -> N.
02:49:24 <tswett> Where const_zero = zero . 1_N.
02:50:08 <tswett> Uh, forget about const_zero, actually.
02:50:27 <tswett> For that matter, forget about id_N.
02:50:38 <tswett> By the definition of a natural number object, there's exactly one arrow f : N -> N such that f . zero = zero and f . succ = succ . f.
02:50:54 <tswett> id_N satisfies these equations, so f = id_N.
02:52:28 <tswett> But plus . (zero &&& id_N) satisfies these equations too, so f = plus . (zero &&& id_N).
02:53:21 <tswett> I'm really botching my categories. There's no such thing as (zero &&& id_N).
02:54:27 <tswett> What I mean by plus . (zero &&& id_N) is plus . ((zero . 1_N) &&& id_N).
02:54:51 <tswett> Where 1_N is the unique morphism N -> 1.
02:55:53 <tswett> Now, of course, since equality is an equivalence relation, this means that...
02:56:12 <tswett> plus . ((zero . 1_N) &&& id_N) = id_N
02:56:21 <tswett> Or, written in conventional pointful notation...
02:56:25 <tswett> 0 + x = x
03:46:27 -!- Naergon has quit (Ping timeout: 245 seconds).
03:50:35 -!- tswett has quit (Quit: Leaving).
03:53:44 -!- erkin has joined.
03:55:40 -!- Warrigal has joined.
04:01:46 -!- Warrigal has changed nick to tswett.
04:09:17 -!- tromp has joined.
04:09:57 -!- sprocklem has quit (Quit: brb).
04:10:30 -!- sprocklem has joined.
04:12:32 -!- sprocklem has quit (Client Quit).
04:12:59 -!- sprocklem has joined.
04:13:50 -!- tromp has quit (Ping timeout: 268 seconds).
04:32:23 -!- imode has quit (Ping timeout: 255 seconds).
04:32:55 -!- sprocklem has quit (Quit: brb).
04:33:18 -!- sprocklem has joined.
04:51:30 -!- xkapastel has quit (Quit: Connection closed for inactivity).
05:03:01 -!- tromp has joined.
05:07:45 -!- tromp has quit (Ping timeout: 256 seconds).
05:26:10 -!- imode has joined.
05:38:57 -!- tromp has joined.
05:41:21 -!- heroux has quit (Ping timeout: 248 seconds).
05:43:13 -!- heroux has joined.
05:43:52 -!- tromp has quit (Ping timeout: 268 seconds).
05:44:21 -!- imode has quit (Ping timeout: 240 seconds).
05:54:24 -!- arseniiv has joined.
05:54:33 -!- tromp has joined.
05:58:51 -!- tromp has quit (Ping timeout: 240 seconds).
05:59:27 <esowiki> [[Roie]] M https://esolangs.org/w/index.php?diff=55447&oldid=55433 * Galaxtone * (-29) Holding off on TC actually, there's a problem.
06:06:03 -!- atslash has joined.
06:22:38 -!- erkin has quit (Quit: Ouch! Got SIGIRL, dying...).
06:22:48 -!- friendlyGoat has joined.
06:23:07 -!- erkin has joined.
06:24:20 -!- friendlyGoat has quit (Client Quit).
06:34:54 -!- atslash has quit (Ping timeout: 256 seconds).
06:38:00 -!- impomatic has joined.
06:50:36 -!- ais523 has quit (Quit: quit).
06:53:46 -!- tromp has joined.
06:55:47 <esowiki> [[Roie]] M https://esolangs.org/w/index.php?diff=55448&oldid=55447 * Galaxtone * (+164) Changed IO so it actually works, Fixed confusion
07:58:47 <esowiki> [[Seeker]] M https://esolangs.org/w/index.php?diff=55449&oldid=55446 * Plokmijnuhby * (+52) It seems like you should be able to do input without doing an operation on it. I think this was the intended behaviour.
08:01:19 <esowiki> [[Seeker]] M https://esolangs.org/w/index.php?diff=55450&oldid=55449 * Plokmijnuhby * (-23) Made a slight mistake.
08:03:27 <esowiki> [[Seeker]] M https://esolangs.org/w/index.php?diff=55451&oldid=55450 * Plokmijnuhby * (-52) Sorry, just read the next section. Maybe this?
08:05:13 -!- atslash has joined.
08:06:15 <esowiki> [[Seeker]] M https://esolangs.org/w/index.php?diff=55452&oldid=55451 * Plokmijnuhby * (+3) /* Infinite counter (using seekers) */ I'm fairly confident that was wrong, anyway.
08:34:18 -!- xkapastel has joined.
08:40:22 -!- tromp has quit (Remote host closed the connection).
08:40:56 -!- tromp has joined.
08:41:06 -!- tromp has quit (Remote host closed the connection).
08:41:20 -!- tromp has joined.
09:22:31 -!- Lord_of_Life has quit (Changing host).
09:22:31 -!- Lord_of_Life has joined.
09:22:31 -!- Lord_of_Life has quit (Changing host).
09:22:31 -!- Lord_of_Life has joined.
09:34:42 -!- tromp has quit (Remote host closed the connection).
09:42:53 -!- trout has quit (Ping timeout: 255 seconds).
09:45:27 -!- tromp has joined.
11:14:29 -!- variable has joined.
11:41:01 -!- variable has quit (Ping timeout: 256 seconds).
11:42:04 -!- plokmijnuhby has joined.
11:42:16 <plokmijnuhby> waddup
11:44:59 -!- variable has joined.
11:54:26 -!- Naergon has joined.
11:56:04 -!- plokmijnuhby has quit (Ping timeout: 260 seconds).
12:02:59 -!- xkapastel has quit (Quit: Connection closed for inactivity).
12:16:55 <esowiki> [[Special:Log/newusers]] create * Akangka * New user account
12:23:58 <esowiki> [[Esolang:Introduce yourself]] https://esolangs.org/w/index.php?diff=55453&oldid=55434 * Akangka * (+199) /* Introductions */
12:24:12 <esowiki> [[OISC]] https://esolangs.org/w/index.php?diff=55454&oldid=54359 * Akangka * (+167)
14:00:37 -!- Guest13947 has changed nick to Lynn.
14:01:07 -!- Lynn has changed nick to Guest31035.
14:16:07 -!- variable has quit (Quit: /dev/null is full).
14:35:32 -!- xkapastel has joined.
14:58:02 -!- SopaXorzTaker has joined.
15:04:00 -!- variable has joined.
15:06:22 -!- variable has quit (Client Quit).
15:44:25 -!- APic has joined.
16:00:22 <olsner> shikhin: you might know alercah from in here?
16:01:39 <olsner> but of course you don't actually need to know anyone to join them in ##:D
16:05:53 <alercah> was about to say
16:24:24 -!- imode has joined.
16:32:56 -!- Cale has quit (Quit: Leaving).
16:36:42 <int-e> that sounds like an extremely silly channel
16:39:07 <shikhin> olsner, alercah: Ah, I see.
16:39:12 <shikhin> int-e: No!
16:43:30 -!- LKoen has joined.
16:45:11 -!- xkapastel has quit (Quit: Connection closed for inactivity).
16:54:31 -!- LKoen has quit (Quit: “It’s only logical. First you learn to talk, then you learn to think. Too bad it’s not the other way round.”).
17:05:18 -!- MDude has quit (Quit: Going offline, see ya! (www.adiirc.com)).
17:09:26 -!- aloril_ has quit (Ping timeout: 260 seconds).
17:24:16 -!- Phantom_Hoover has joined.
17:26:29 -!- izabera has changed nick to motaneva.
17:27:06 -!- motaneva has changed nick to izabera.
17:36:43 <esowiki> [[OISC]] M https://esolangs.org/w/index.php?diff=55455&oldid=55454 * Ais523 * (+2) /* List of OISCs */ grammar
18:10:54 -!- contrapumpkin has quit (Read error: Connection reset by peer).
18:12:35 -!- tromp has quit (Remote host closed the connection).
18:15:53 -!- contrapumpkin has joined.
18:57:14 <shachaf> Is there any high-level language that has conditional goto?
18:58:38 <Guest6451> is that fancy talk for an if
18:59:09 <Guest6451> also probably not
18:59:12 -!- Guest6451 has changed nick to Slereah.
18:59:23 <shachaf> It's fancy talk for "if (p) goto q;"
18:59:57 <shachaf> Also it doesn't have to be that high-level.
19:00:13 <shachaf> I just want it to be in terms of an expression argument instead of a flags register or something.
19:00:37 <Slereah> Well assembly has them
19:00:42 <Slereah> Not very high level
19:01:41 <Slereah> As high level languages got developped goto became a big taboo so I don't think there were a lot of variants
19:10:15 -!- arseniiv has quit (Ping timeout: 260 seconds).
19:12:05 -!- SopaXorzTaker has quit (Ping timeout: 256 seconds).
19:24:09 -!- aloril has joined.
19:32:11 -!- wob_jonas has joined.
19:32:40 <wob_jonas> shachaf: yes, there are basic-like languages that have only an IF comparison GOTO label statement, not a full IF THEN
19:34:00 <wob_jonas> shachaf: in particular, the simple programming language of my sharp el-5120 programmable calculator only has such a conditional statement. the comparison uses one of the six arith comparison operators, with basically any expression (including complicated ones) possible on both sides of that operator
19:35:16 <wob_jonas> some older programmable calculators from before precedence expression parsing also have some comparison-goto statements, although usually it's just comparison to zero
19:37:27 <wob_jonas> whereas older intercals and older APLs only have a computed goto, rather than a conditional one
19:37:51 <wob_jonas> although intercal's is somewhat limited
19:38:09 <wob_jonas> it's not a real computed goto, just a BASIC-style switch-goto
19:38:27 <wob_jonas> (which is written as ON expr GOTO labellist in BASICs)
19:40:14 <wob_jonas> and... hmm, I don't know the history here, but don't some older fortran variants only have if-goto? or do they have single-line if like traditional BASICs do too?
19:40:16 <shachaf> Makes sense.
19:40:40 <shachaf> Did you see the thing I said about blocks yesterday?
19:41:21 <wob_jonas> plus FORTRAN has that unique "three-way if" statement that is a switch-goto with exactly three targets depending on whether the controlling expression is zero or negative or positive
19:42:00 <wob_jonas> shachaf: do you mean about the destructor exceptions? I wanted to say something about that too
19:42:19 <shachaf> Yes, except now I think destructors are kind of a red herring now
19:42:27 <wob_jonas> in C++ and some other languages, you could query in the destructor whether it's currently unrolling exceptions or not
19:42:49 <wob_jonas> so if you test that and only run your cleanup if they aren't unrolling, then you get what you asked for
19:42:54 <shachaf> Yes, I saw that. But unwinding the stack due to exception is pretty special, more special than break/early return.
19:43:15 <wob_jonas> alternately you could use a non-local exit mechanism and a destructor that aren't compatible with each other, so that non-local exit doesn't properly unwind the stack.
19:43:25 <wob_jonas> ah, I see.
19:43:27 <shachaf> I bet ternary computers have a three-way if.
19:43:38 <wob_jonas> well, in ruby 1.8 those are implemented very similarly
19:44:10 <shachaf> Oh, I remember all these features of Ruby 1.8
19:44:16 <shachaf> redo, retry, all those strange things
19:44:22 <shachaf> Did they take some of these things out?
19:44:30 <wob_jonas> I don't think so
19:44:33 <wob_jonas> and those aren't strange
19:44:46 <wob_jonas> those are just like gotos with lexical targets, as in
19:45:36 <wob_jonas> if you have a function call with a block passed, written as either f(args){block} or f(args)do block end; and it basically makes a lambda of that block and passes it as an argument in a special place and
19:46:12 <wob_jonas> in the impl of the function f the shortcut yield statements calls that callback, but instead of calling it can also just store that callback and do whatever it wants;
19:46:54 <wob_jonas> so anyway, if you have a call like f(args){block} then imagine you put goto labels in it like this: label RETRY; f(args) { label REDO; ...; label NEXT; } label BREAK;
19:47:24 <shachaf> In Ruby you can write a regular while function that can be used like while(p) { ... }, right?
19:47:27 <wob_jonas> and then the four control statements go to those four labels, only they remember the right labels lexically even when you're multiple levels inside such calls
19:47:33 <shachaf> That's a pretty unusual feature for a function, I think.
19:47:46 <wob_jonas> except that these loop controls also apply for some built-in loop statements other than those syntaxes
19:48:23 <wob_jonas> shachaf: no, that wouldn't work firstly because "while" is actually a keyword with a different syntax, secondly because you'd need to make a lambda of the condition too because it has to be evaluated multiple times
19:48:45 <shachaf> No, that's the weird thing about retry, the way you wrote it.
19:48:53 <shachaf> That you can have the argument to the function reevaluated.
19:49:01 <wob_jonas> but yes, you can write if and while conditionals that way, and that's how smalltalk and postscript etc do it
19:49:10 <wob_jonas> whereas ruby has a couple of builtin syntaxes for those
19:49:25 <shachaf> I thought in Ruby you could do it without a lambda.
19:49:31 <wob_jonas> shachaf: yes, but it's still just a goto, only with a lexical label, and ruby doesn't normally have gotos
19:49:50 <wob_jonas> shachaf: I don't think you can
19:50:07 <wob_jonas> the function f can't call retry to recompute its arguments
19:50:20 <wob_jonas> it's onlk the brace block that knows (lexically) where that label is
19:50:25 <shachaf> wob_jonas: See http://ruby-doc.com/docs/ProgrammingRuby/html/tut_expressions.html#UM
19:50:30 -!- user24 has joined.
19:51:02 <shachaf> I'm trying this now in Ruby 2.5 and it says it's an invalid retry.
19:51:17 <shachaf> So maybe this *was* removed sometime after 1.8.
19:51:39 <wob_jonas> for "for" and "while" loops, two and three respective of those control statements are the same as the two and three control statements of C and perl respectively.
19:52:05 <wob_jonas> it's only logical that ruby added a fourth one, and that it allowed them arbitrarily deep with the lambda lexically bound
19:53:41 <wob_jonas> but for more complicated loops, they're different:
19:54:35 <wob_jonas> in perl, the control statements will act on the actual innermost loop, not on the loop that's in the lexical context of where you put the loop statement, which can get to broken invariants if the loop is in another function that doesn't expect you to use loop control statements on it,
19:55:16 <wob_jonas> and the same is true if you use loop labels in perl: with those you can distinguish different loops, but among two nested loops with the same label (or two recursive instances of the same loop code), the loop control statement will act on the innermost one.
19:56:05 -!- tromp has joined.
19:56:32 <wob_jonas> ruby has actual lexical loops, although you could simulate them in any language if you have call/ec or selective exception catching checking the value of the exception not just the type
19:58:08 <wob_jonas> the part that I find strange is that many of these languages with these powerful control constructs are reluctant to support gotos, despite that there is little or no technical difficulties implementing them. ruby doesn't normally have gotos, although I think there's some non-vanilla hack adding them; python doesn't have goto; lua does have goto no
19:58:08 <wob_jonas> w but didn't use to have it for a while;
19:58:33 <wob_jonas> and rust doesn't have goto yet, but I hope people will eventually agree to add one after the rewrite of the borrow checker.
20:00:26 <wob_jonas> luckily perl has a goto (and it's quite powerful a tool too, but still only syntactical if you try to goto out from a lambda body), and C++ has a goto too (with some limitations)
20:01:40 <wob_jonas> languages should just add goto and come from (plain one, not computed one; the computed one is much more difficult).
20:02:14 <wob_jonas> non-eso languages that is
20:02:23 <wob_jonas> some esolangs have good excuses not to have it
20:37:29 <\oren\> wob_jonas: I don't understand why more languages don't have unless aand until
20:48:02 <wob_jonas> \oren\: I don't like those these days
20:50:35 -!- impomatic has quit (Ping timeout: 260 seconds).
20:58:40 <shachaf> Is there something like continuation-passing style in low-level languages that don't support closures and so on?
20:58:55 <shachaf> Maybe that's what I'm looking for.
20:59:17 <shachaf> SSA is one sort of answer.
20:59:29 -!- Cale has joined.
21:02:33 <wob_jonas> shachaf: you just emulate closures by storing a state and all upvalues in that case
21:03:28 <shachaf> Well, yes.
21:04:27 <wob_jonas> and then you optimize that by having a persistent structure that stores most of your values, rather than creating a new structure for every state
21:04:33 <wob_jonas> object-oriented style
21:19:12 -!- wob_jonas has quit (Quit: http://www.kiwiirc.com/ - A hand crafted IRC client).
21:25:22 -!- user24 has quit (Quit: Leaving).
21:28:05 -!- Naergon has quit (Ping timeout: 256 seconds).
21:54:29 -!- Naergon has joined.
22:08:56 -!- friendlyGoat has joined.
22:09:01 -!- friendlyGoat has quit (Remote host closed the connection).
22:15:12 -!- atslash has quit (Quit: This computer has gone to sleep).
22:21:00 -!- atslash has joined.
22:24:57 -!- atslash has quit (Ping timeout: 240 seconds).
22:25:31 -!- Elronnd has changed nick to Elronnd`srn.
22:25:37 -!- Elronnd`srn has changed nick to Elronnd\srn.
22:35:16 -!- Phantom_Hoover has quit (Remote host closed the connection).
22:53:08 -!- xkapastel has joined.
23:00:07 <shachaf> ais523: So I think a pretty natural way to express "for x: ...\nelse: z" is "loop: { for (x) { ...break loop...; }; }", if you have labeled breaks.
23:00:58 <shachaf> Also, blocks should support return values, and return should just be the same thing as break?
23:01:05 <shachaf> Then inlining is very straightforward.
23:01:23 <shachaf> Also ais523 isn't here. Maybe he logreads.
23:01:38 <shachaf> Apparently Rust recently got support for return values for blocks.
23:11:56 -!- Cale has quit (Remote host closed the connection).
23:19:34 -!- Cale has joined.
23:24:49 -!- ais523 has joined.
23:33:21 -!- Cale has quit (Ping timeout: 240 seconds).
23:44:49 -!- Cale has joined.
23:48:21 -!- danieljabailey has quit (Ping timeout: 240 seconds).
23:56:08 -!- danieljabailey has joined.
←2018-05-29 2018-05-30 2018-05-31→ ↑2018 ↑all