Live CEOing Ep 669: Language Design in Wolfram Language [TestApplied, Echo Functions, and More]

Stephen Wolfram and team discuss two language features: a ContentPadding option to fix whitespace when converting cells to bitmaps, and TestApplied, a higher-order function that conditionally applies operations only when inputs pass a test. They settle on calling it failSafe, with automatic failure detection and a fallback that returns the first failing argument.
Chapters
Sam. Okay.
Hi, everyone. Welcome to another Wolfram Language Design review. This is part of our Language Completeness and Consistency series, and we have three topics here that all look straightforward, but those are always. I love the way that that induces an instant cackle. Okay.
Yeah, yeah. I mean, I think. Well, as a jet. Well, I suppose we do have the occasional straightforward topic, but.
Right. It's very rare. Okay. Right.
So just to bring us all up to speed, right? So if you look at that first framed image, right. If you click on the W and P, you'll see that, Right. They're both the same size and they, you know, are filling up the box. And then. Because. Right. You don't rasterize an expression. You rasterize a cell. So if you rasterize something, it has to typeset it and then stick it in a cell. And then that's.
Hold on. What are we actually seeing here? We're seeing. I see. We see.
It's. It's the full. It's the full ascender and descender in every case. Basically a full line height.
Right. And the problem with that is that if I'm labeling a plot with a P, it's got a bunch of, you know, and it's a bitmap. I've got a bunch of crud around.
The P.
Well.
Which I would say to. The solution to that is to make the background transparent, and then it doesn't matter much.
Yeah.
I don't know that anyone really cares about bitmap labeling a plot case.
Oh, you know, we do. We do care about that. We care about it for machine learning kinds of things.
And also, what I was just going to say was the case that you had raised was. Was machine learning. I thought it was a training scenario.
No, it was. It's labeling a feature space plot, for example. I mean, you want me to demo.
Why do they use bitmaps?
Because that's what it's. Look, look, here's the case.
You'd say, yes, well, okay.
Okay, this is going to use. Okay, those are bitmaps of those letters. Right? Now, we don't see anything bad happening here, but if I were to do. I bet I can even make something bad happen here. Okay, that actually looks quite good because the descenders all, you know, it all lines up. The baselines all line up in that case. So we win in that case by having this sort of full font bounding box.
Right. I mean, I think the I. The issues where you come up with this is, you know, if you. If you're doing Right. If you have like a pane or a graphics and you know, you specify an image size to that, but, you know, then you get a, you know, a couple of pixels off because of whatever selling this leaks into it or, you know, that's the case where I've encountered this issue and I'm not 100% convinced that the proposed option actually fixes the issue due to other issues that it introduces. But. And the other case is where you might want. So if you scroll back up to the WP example. Right. I think there was some desire to get a thing that looks like the third bitmap. This, this was an example from some meeting I was not in, but apparently where this was discussed perhaps in relation to eiwl. And so in the third one, right. They're both sort of right next to each other and full size and sort of the issue is, right, if you just sort of trim to the, you know, trim out the white space, then what does image size apply to? So if you click on the middle frame, you'll see that the W is full height, but the P is simply centered because, well, it's in a row, but all that white space was sort of trimmed away.
All right, let's.
Or may not be what you want.
Let's zoom out for a second. So wait a minute, if I do.
And, and actually the mismatching sizes, I think are misleading because the. Something crossed the threshold there where the, the W ends up with the magnification, some auto magnification getting applied. Because, you know, because we apply magnification, the bitmaps that start to get too small.
Oh, okay.
So. So if you right click the W and choose actual size. And right click. And right click the P and choose actual size.
Thanks, John. I. Oh, okay.
So that matched height and the one below matched width. Is that right?
So then the one below, I sort of resized them both to be the same size as the original W.
Yeah, I actually used the image resize operation below.
All right, but let's zoom out.
So is it, is it like just.
Well, so if you take a close look, you can see that the, the P is just ever so slightly taller than the W. And I think what happened, I mean, there literally is a threshold where it's like, you know, use default magnification, then cross the threshold and step up the magnification because the bitmap is considered too small. And those steps are discreet in such a way that it can look very odd when, you know, when you cross that threshold.
Okay, but.
Right, but. So for Example if instead of a P, we had an A there, then we would have sort of a centered A in the middle example.
Correct.
Because presumably that would be less tall.
Than a capital W. Yes, that would be my expectation. The second example uses image crop. So just rerun this the second example, but add an A to it. Right.
And again, we want to have to.
Do the actual size. Yeah.
How do you do that? Programmatically?
Wrap image around the whole list and say image size all.
Okay, so that is. Is writing.
So now you can see the A is significantly shorter.
Yeah.
Whereas the P is. You might not have expected it, but the P is, like, ever so slightly taller than a capital W. And why.
Is there so much space across the top even?
Right.
I've set frame margins to none and content padding to false.
I'm not sure. That might just be an update issue after redoing the magnification. I'm not sure. I'm. I'm not sure what's going on.
Okay.
Might be a bug, though.
Yeah, it might be.
Okay. All right, so what is. So the issue here really is, do you want consistent boxing for the whole font, or do you want shrink wrapping for an individual element?
Right. That's right.
Are those the two possibilities? Is there anything else?
So, so, like I said, I, you know, I don't care so much about the, The. The. The texty case, because I think basically what you do want is, in fact something that looks like a line of text in a cell. But what I get is, you know, I create a panel or something or a tape, which I make to be, you know, 400 by 400 points, I guess, not pixels. And, you know, then I try to rasterize it, and it's, you know, 402 by 400, you know, after I've adjusted, converted between points, because that extra little bit of stuff around it, you know, from being actually part of a cell, is. Is an issue. But I don't. I'm not sure that this actually solves that problem.
Well, it's. It. It solves it by introducing a potential new problem, which is that you might end up with something that's like 390 or 380 instead of 400, because it would effectively trim off, you know, the unused space around the edges, which could include part of that 400 width that you had specified or 400 height, I guess. Sorry.
Okay, so hold on. Content padding does seem to be the relevant option here, correct?
Well, it's an option for things like brain.
It's a box option.
Right.
But its functionality seems relevant for this, isn't it? I mean, it's the thing that makes these guys different sizes. It seems like it's the right option that you picked.
Yeah, well, it's. It's a. It's a little weird because, I mean, it's been exclusively used as a box option, not an option to a kernel function that actually makes transformations. Now, maybe that's not a strong enough.
Argument to say any different. I mean, look at it seems like it's exactly the same thing it's doing here.
Well, I mean, I would say it's a little different. Right, because it's the difference between, you know, what I'm adding this extra layer. Do I put a buffer between.
The.
This layer and, you know, this new. This new wrapper and what was already there versus, you know, do I somehow shrink to what's visible?
I understand, but isn't that exactly what this is saying? It's either using the full line height. I see. Not least one full line height. What is the line height is relative to the font height.
Right, Right. Line height is defined by the font.
Okay, so. Okay, so what's wrong with just having this content padding arrow true or false? Would that. Would that get the functionality we want? So content padding, our content padding arrow, false.
We'll have to rewrite this documentation a bit to accommodate that.
Right?
I mean, because it's no longer an option for objects.
No, I understand that. I mean, but does that. Okay, so the two choices are it shrink wraps to the individual object.
Right.
Or it does it for the line height and it's. It's only height that's relevant. It's not width. Is that true?
Correct. It's. I mean, this is basically that.
I guess that depends on. On what we want this option to mean and rasterize.
Right?
Because there are certainly cases where is that true?
If you're asking, does content padding, for example, horizontally pad a monospace character to guarantee it's monospacing? I haven't thought about that question.
No, no, no. The question I'm asking about, I mean, you can certainly make something where I'm trying to think of if there's a case when you rasterize something where the thing you want to trim off is actually the sides and not the top.
And bottom rotate the raster. But I don't think that really counts. But I also.
That's a post rasterize operation.
Okay. Okay. Assume it's not single letters, but it's some whole complicated thing. This whole question about whether there's space around the bounding box. The primary reason there's space being left around these bounding boxes is because font heights. If we had something like in the example down below for content padding of one half that doesn't have any padding anyway. See what I'm saying? There is no content padding for one half. There's only content padding for things which are font things which are part of a family.
There.
Yeah. There is no in. There is no external content padding to. To one half. There is a bit of internal content padding.
Okay, but I mean, but this content padding option would apply only to the outer, outermost thing, and it will apply. Can be applied to the 1/2 just as it can be applied to the A. Right. Except that for one half there is no line height. If one half was tiny compared to the line height, then it would pad to the line height, presumably.
Right. Well, you know, and you can artificially force these kinds of scenarios. You can, you know, you can have, you know, wrap style boxes around the numerator and denominator that make those individual things incredibly small and thereby shrink the fraction below the ambient font size of the whole thing.
So you're saying take this and I take that, for example.
Just. No, no, no, no, not around the entire fraction around the. Individually around the numerator and the denominator.
Okay. Kind of. Unfortunately, I have to delete these double quotes separately. You like me to make this very small?
Yeah.
And the one below.
And the one below as well.
Same smallness.
Sure.
And yeah, so.
Oh, God, that's a big mess. Okay, let's say I can get up to eight point. Why the heck is that? First one with content batting out a false. I don't get this. I don't get what's happening here.
So.
Type a. Type anything next to. Next to the. Those boxes. Out. But. Out. Oh, oh, sorry. That's. This is a grid. Okay. Yeah. Okay. Okay. So. So the issue here is the size of the box around the A on the upper right. That's the guide because that's the size of the font for the grid box.
Yeah.
Now, and because we reduce the size of the numerator and denominator, we actually made the fraction as a whole smaller than that size.
Yes.
It's not something that would typically happen if you didn't play games with the fonts, but you can play games with the fonts to make it happen.
But I mean, this is the ambient size. But as soon as I put in different styling for Individual elements. You're saying that the grid as a whole gets its sizing from the ambient style, not the style of its individual elements.
Yeah, so. So all I'm saying is the box on the lower right is coming from what, a 15? It's based on a 15 point font. I think it is whatever the ambient font size is. I think it's 15 in this case and not the eight point guys that are found at a deeper nesting. Yeah, that's all I'm saying.
I understand. So everything is based on the 15 point thing. So this thing, this whole, whole box arrangement is based on that, which is why there's all this empty space.
Yeah, yeah, exactly. I'm not, I'm not saying I'm worried about this case. I'm just saying there are exceptions and they look like this.
Yeah. Okay. Okay, so let's come back to what we were talking about. So, I mean, this definitely should go into possible issues for this thing. But, but, okay, so the concept is content padding arrow false. Does it sort of one letter at a time? One. The what you see is what determines the padding as opposed to content padding arrow true, which is what font you're in determines what padding. Is that correct? Yeah, seems okay to me. Anybody got an objection to this? Nope. Okay.
Well, I, well, I still, I mean, I guess this, I, I'll just reiterate, I guess that it is a bit weird that this thing that, you know, was sort of a box level option is now being turned into a kernel function option.
I don't consider that that weird. It seems like it's doing exactly the same thing, unless I'm missing something. I mean, it literally seems identical. Check it out. Try never. But it looks identical to me and I don't see a problem. It's only us that knows kind of what's a box option versus this option versus that option just doesn't seem problematic to me. Anybody want to comment further on that? Who's here? Who would have other.
I, I, I'm, I'm not objecting. So.
Right, same here. I think it's fine.
Okay.
Okay.
Carried on to the next item. Test applied.
Yes. So this is a very, this is like from two years ago or something, but there's a prototype of it here. Basically the function is in the family of operator applied and stuff like that. Sort of a function that eats a function. And its main purpose is if you have, let's say, a chain of compositions and one thing in the middle of the chain might return a missing or a failure or something like that. And you want to be able to sort of pass it down the chain.
This lets you do that, or up the chain, rather. I mean, in other words, by test applied.
It lets you do the. The idiom, you know, if hash, if missing Q of hash, then hash otherwise F of hash. It does a little more than that, but that's like the, the simplest case, right?
So if the test. If applying the test succeeds, then run this function. Otherwise run this function here.
Right. So that's the complete.
Yes.
Right. And then there are implied defaults for. For the third argument and the second argument.
Right.
So the two complicating things are. I mean, otherwise it's a very simple function. The two actually maybe three complicating things. One, what's a failure? Right now I'm just following what confirm does, which it's like failure queue or missing queue, or if it's dollar canceled or dollar aborted or something like that. The next thing is what the defaults are for the different arguments, arguments two and three. And the last one is the varargs behavior, if it has any.
Ok, so the basic point is, in the case where I just give. Ok, hold on, let me understand this.
There's.
By the way, there's an implementation if you run the INIT thing that'll probably be useful.
Where is the init below?
Right, Right below. It's the. Why I told you you should run the INIT cells.
Okay, okay, fine. All right, so then. Okay, so here, this is only going to fail. What the hell is that?
It's only running square root if the thing is.
Oh, I see. Yeah, yeah, right, right, right. So I remove that and now it's only going to trigger on the missing. Yep. Where.
And a default behavior passed it through unchanged.
Right, I understand. As opposed to. If I said square root of missing.
You'D get square root of missing.
Yeah.
Right. So a really useful example that shows potential VAR behavior is Right, right.
This.
Right. You know, test applied of divide comma hash 2 is not 0. Yeah, just that. And then map that over, you know, some, some, you know, list of lists where some of them might have a zero in the second argument.
I wanted to triple that.
Sure. Oh, yes. Yeah.
Oh, no, no, I don't want to do that. No, no, I don't want to do that. You were right. It was just about.
Wait, no, no, no. It should be triple at.
No, it's hash of two there.
And then. No, it should be hash hash two.
This is.
I was trying to show the vararchs behavior I'm sort of confused why it's not even showing the. Can you just replace the test replied with an F just so we can see what's going on. And, and, and you should do triple at instead of ampersand. Slash @. Get rid of the ampersand for.
Sure. That's probably the. Yeah, that was the problem. That would. That was the ampersand.
Was. Oh, was there?
Yeah. Okay, there you go.
Yep. Right. So you see here, basically the. All three functions. The third argument is kind of irrelevant. I mean, it's basically the what to do if it fails. But basically all three functions are all varargs and they all just take all the arguments that get passed into test applied. So the test gets to see all the arguments, the function itself gets to see all the arguments and so.
On. Right, I see. Okay.
Yep. I mean, this thing with divide, for example, you know, I've written a million.
Times. Yeah. Okay, let me think about this for a second. So this is, by the way, the confusion that we all had about the fact that this needed a function, that this itself, the test applied was itself a function. I don't think the name test applied is obviously.
Horrible. Well, it kind of makes it sound like you're applying the test.
But. Yeah, exactly.
Right. I was.
Applied. There was a notebook, I mean, again from two years ago, there was a notebook where we spent like an hour or something talking about names for this and one other thing, and I think there were a lot of different ideas for it. So if we're going to talk about naming, we should get those up. But. Yeah, maybe find it. Yeah, I'll have to find it real quick. Thanks. It's on the JIRA.
Ticket. Okay. I might be able to find it too. Let me just try to open.
This. Well, we were also talking about some other things like replace missing and so.
On. This is the beginnings of supplied.
Here. That's way newer, isn't.
It? I have no idea. I.
Just. I remember I looked that I wrote this like, I think November of two years ago. Like November of. Okay, 2020 or something like.
That. My God, that was already during the pandemic period. Wow. We'll just. I don't know. Okay. Did the. Ah, Avery, you found a bunch of these. Is that. Did you find everything, do you.
Think? Let me send you a notebook. Yeah, there's a lot of names you.
Had. The Q words are not.
Right. Right. Well, that, that's because we were talking about that. There were two. Another thing we were talking about, which isn't here, was basically having what we eventually, I think decided would be a two argument failure to argument failure. Q for asking, you know, because right now failure queue basically just checks. Does it dollar failed or is it underscore failure? But the idea is we'd have other versions that also check if it's missing and also check if it's whatever else. Okay, that's a different discussion.
Though. What is when you have a test is. Is it. It's confirmed test. Right. That's the version of test confirmed.
By.
Ah.
Okay. I mean we could have something like apply if. Right. Like apply this if this condition is met. Otherwise.
Don'T. Unfortunately, it's a little bit cryptic. It's a construct. Non.
Apply. No, it's apply, isn't.
It? No, it's.
Not. No, it's.
Construct. No construct takes, you know, F comma XYZ and constructs F of X, y, Z. This is apply of F of XYZ turns into F of X Y Z. Can you run apply of F of X y Z? I'm not sure actually if the level specs all work out, but. Or like. Like if it's by default at the right level. But is there any function though that does. I like. I think this is a ply. It's just at the wrong. Or maybe. Or is it operate or.
Something? Okay, it does.
That. Yeah, but that. That is. Wait, let me.
Look. I'm pretty sure this is construct because it's. Isn't it.
Construct? I don't think it's.
Construct. No, it's not construct because construct will be F of X Y does.
That.
Yeah. Whereas what we actually have. There is no name. It.
Is. Well, it actually does have a name. It's called Identity. Identity of F of X Y Z returns F of X y Z. At best it's Maybe operate is close. Actually, no, Operate is. It would be operate of F comma. I know that's just F, the list X1.
Yeah. Okay, well is this like operator applied or something with some. Maybe that's where this name came from. But. Right.
Like. Yeah, it's like operator applied, but it isn't.
Operator. But with useless arguments. Yes. If you tell it to do. To just pass through.
Everything.
Right. You know, I got to tell you, Test applied is not the worst name for this. Well, let's look at the pipeline. Let's look at what one of these pipelines would look like. Give me an example of something where we say image crop. We still have shoddy here. Not shoddy.
Drop. Well, image crop isn't usually fail. I Mean, if you give it good arguments, it'll basically.
Work. I just want a pipeline where you've got to give, you know, some standard. Go.
Ahead. The most common examples I have are either things where there's a missing in the middle or like a zero that you don't want to divide or an infinity or something the middle. So for a missing anything with entities, you can get a missing in the middle of.
Anything.
Right. So if you could just give me a real example. Let's just type in a real example. Let's say image processing pipeline or from any other.
Pipeline. Well, let's say you're mapping over countries and you're getting their populations and then you are. This isn't a.
Group. Right. You want to calculate their density. So you get the populations and the areas and you divide them. But if one of them is missing or. Or hopefully none of them is zero.
But.
Right. Run into.
Trouble. Okay, so let's take this as an.
Example. The only thing is, I'm not sure that we're going to be able to write this nicely as like a chain of compositions, but. Yeah.
Let'S. This. So that thing there is a function. Okay. And you know what I want to do? I want to do a total of this. Actually. Why would I bother with test applied then? I want to.
Do. Well, the test applied I think you want to do. The hash of population will almost certainly work. The thing that won't work is whatever comes next because the result of hash of population will be a.
Missing. No, I understand that. Okay, so I want to just do squared.
Here. Right, but what you should write is you should write hash of population. Yeah, no, but the test applied should be around the squared because that's what will.
Fail. No, it isn't. This will give a.
Missing. Right, that will give a.
Missing.
Exactly. Test applied only checks if they're missing the arguments. If you want to do that, that's what confirm.
Does. Okay, so hold on. Test applied of hash here.
Squared. Yeah. No, the function in the.
Test. Pound squared, ampersand close.
Bracket. Where in.
Here? Yes, yes. Test applied takes a function and it makes a new version of the function that just passes failures through.
It. So.
You. Oh, I see, I see, I.
See. So you need that bracket to the right of the.
Ampersand. It's pretty subtle. Okay, and then this thing applied to hash of.
Population. Yeah, I mean, maybe compose it if you want to be stylish. Because that's. We're kind of talking about chain composition things.
Here. But yeah, okay, fine. Let's compose that which you mean at.
Star. Yeah, and you'll need parentheses, I think, and then just map it over like entity list of country. Horribly inefficient. I mean, you should just do it with entity value. But. But.
Whatever. Does that.
Work?
That. I don't think that works. No.
No, But now I have to ampersand.
That.
Yeah. And then I take the whole thing. I have no idea about the.
Precedence. So look, look, it's correct for map. Yeah. Actually, list of country. And then presumably, like Antarctica or something will fail. Why? I still don't know why Antarctica is a country here, but.
Whatever. Well, let's say entity list.
Of. I mean, they're almost all going to succeed for population. That's. That's why I'm telling you.
Antarctic. I know, but I don't. I want to get an entity list.
Here. We're just saying to the list of country quotes.
Country. That's just going to be a lot of places. Let's watch our caching in.
Action. Well, you could do country part, you know, you could do take of country. Come up, you know, 10. Because Antarctica is alphabetically quite.
Early. Why is it so centrally.
Slow? Because it has to make 200 requests. But.
It'S. Let's freeze it out, so to.
Speak. I mean, well, if you did. The real thing to try is if you do. Yeah, I know, I. I know that's the much more efficient way to do it. But. But we're trying to write it with. Yeah, yeah, I guess you could. I guess you could just do entity value of country, comma, population, and then map the test applied over.
That. Where's Antarctica? That looks like.
It'S. Unless we finally fixed it and we no longer have Antarctica in the list of.
Countries. Yeah. Can you just run entity list of country just to see what the. You know. Oh, there it is. There's number nine. So you gotta. There we.
Go. Okay.
Okay.
Right. Except I have no idea what test applied means. Right. It's like I'm taking this test and applying it, but no, I'm right. I'm not taking a.
Test. No, you're not. You're not. You're.
Not. Yeah.
It'S. It's, it's really. It.
Is. Most of the time. By the way, you're not going to pass in a test at all. Like, you're going to use the automatic test, the default.
Test. Right. I was going to. I'm not. I mean, I'm not suggesting this is a good name, but I feel like test Tested apply is at least closer in spirit. And I'm doing some testing before I carelessly apply dysfunction, confirmed.
Apply. Although I don't. I usually don't like the confirm names that aren't actual confirmed enclosed functions.
But.
Clean. I mean, really what it is, it's like a safe version of your function. I mean, it's like. I mean, this is not a good. This is too vague. But like, it's like saying safe of F, and now you know that F is something that can take, you know, or, or, I don't know, error.
Ignorance, protected of F. But it isn't protected of F. It's kind of.
Like it's, it's. It's sanitized of.
F. Right?
Yeah. Well, what do you mean it's sanitized? It's not the F that's being sanitized. It's the. It's the thing that's coming into F. F doesn't want to eat. Look, right? F is going to reject any food that has dirt on.
It. So, so do you. So, so should it be sanitize of.
F? That makes it sound like it's sanitizing. I mean, we can either talk about. We can either talk about sort of in the phrasing of F is a function that only takes clean stuff. So please, now that I've told you this, make sure everything is clean. Or we can talk about it as like a verb that's like. Well, or we can talk about in reference to the arguments and say this is a thing that will clean up the arguments and give them death, if you understand what I'm.
Saying. No, but it's not cleaning. It's not cleaning up any arguments. It's just punting F. Okay.
Sure.
Yes. Right. It's.
Rejecting.
Right. We can have a descriptive term that's describing F, or we can have it as like something.
That'S. That's like more verb, like sanitize.
4 of F. No, but it isn't. You.
See. Yeah, it's sanitizing for plot or.
Whatever. Yeah, yeah.
Ridiculous. When I have that, it sounds a little bit like a for loop, but.
Yes. See, the problem is that we're not like sterilizing, decontaminating, whatever, effort.
Itself. Exactly. That's what makes this hard to.
Name. But you could, you could talk about it as. What would you call a function that. That. That should never be given, you know, an error coddle of F. Toddled.
Right. I mean, look, protected of F. If we hadn't used protected for a lot of other.
Things.
Right. Well, maybe it's kind of the opposite of Protected. I mean, depending on how you phrase how you're phrasing it. Right. Like it, it's, it's, it's avoid.
Calling F. Avoid calling F if it is a version of F that. Where it doesn't call the F if it isn't good. Reject all food that looks bad and you know.
Pass.
Pass. Okay, here's, here's another way to say.
It. But yeah, again, just, just.
To. On nothing that is. That looks bad. Engage only when it's, you know, Engage only when it's something.
Good. Right. Again though, to be clear, there's two. You can either name it like picky of F to say basically this is, this is. We're making a version of F that is picky. Or we could call it something like, you know, afraid of failures of F, which is more of like a tag to say F is afraid of failures and you should never give it one, if you get what I.
Mean. I.
Understand. Yeah. Although in a sense it's really unpickify of F. Right. Because F can now be fed missings and they just sort of. That's not a problem.
Anymore.
Right. Well, unless you view it as the second version where it's. We're telling you F is picky. But. But.
Yes. Yeah, I don't think that's the right thing. I think, I think it needs to be. Look, basically this is.
Basically. Or should it be pre screened of.
F? That's.
Interesting. I do think, by the way, this is one of those names that would be good to be short again because I think like Operator applied, for example. I think part of the Killers. It's too long. But yes, Nick Mertzen gave the suggestion maybe monad. So maybe apply. Or very like maybe maybe a.
Monad.
Right. There's the maybe monad. Right. There's a list I gave at the end of the section below. There's sort of similar things in a bunch of different languages. I mean it's the same as option in Rust. It's the same as optionals and Swift or like the optional chaining operator.
Relations to other languages has these, these.
Names. Actually there are some really crazy names like Rust. Right. Rust has map and they have a thing called and then. So you have your thing and then you say dot and then and I have never. There's and then. Then there's also then and there's also and. And I never keep straight. You know, which is which. Right. And then. And then.
Haskell. I don't think any of these are any.
Good. Right. Haskell has functor.
Man. Great, that's gonna help.
Everybody.
Right? That's.
Ridiculous. Swift is the best one, which is just that if you have. I mean. Cause they. They do everything with methods. Right? So if you have something that's a. Maybe basically an optional type, instead of writing dot foo to. To, you know, apply the foo method, you. You write question mark dot foo.
But. Yeah, I.
See.
Yeah. That is the analogous thing for us would be instead of writing F of X, you write F question.
Mark. Right, right. So this is. So instead of F at X, it would be sort of F question.
Mark at X. Yeah, I mean, I don't think that actually works for.
Us. But you know, and unfortunately we. Because we don't have a name for the at really, other than sort of the strange. I mean, as you say, the only name for the. Okay, hold.
On. So this needs to be the at the F question mark. Open bracket X would. Would theoretically work as. Well. Again, it doesn't work, but yeah.
Yeah.
Right. Okay, so hold on. What is this really doing? This is. What the heck is this doing? Okay, what will be the sentence that we would say? Okay, so we say blah and.
Put a suggestion in.
Chat. Okay, Well, actually, what we have to say is rather this. We have to say blah of F of.
Exper.
Yeah. You know, basically it just gives F of X, F of expert. If expert is not considered a failure and expert.
Otherwise.
Yeah. Okay, come on. There's a way to do this. Okay, what is this doing? This is. It's wrapping F to say if you don't like what you're being fed, just spit it.
Out. What about something like on.
Success. On success or unsuccess.
On. Oh, success. Run.
This. Yeah, I think it's weird to think of two as being.
Success. Well, but imagine you write on successive F, you know, of entity value of blah, blah, blah. So you're saying if the entity value succeeded, then do.
This. Yeah, but. I know, but the success seems to come from the wrong place. It's kind of like.
Like. Well, there's also the question of. What about the, you know, the divide case? Right. I want to apply divide. You know, if. If one of the. If the number. If the denominator is zero, is that really a not a.
Success? If valid of F, if. Safe of F. But it's not.
The F itself, you see, it's if. If the food. If. If.
A.
Right. What's saying F do F if valid.
Right? Yeah, on.
Condition. Wow. There's some maybe conflicts.
With.
On. Okay, hold.
On. We could call it conditional and then we would have to explain how it differs both from condition and.
Conditioned. Maybe we should call it on and it will just do something baffling if you give it a message.
Name. I was about to point out that we already have something in common, but then you preempted.
Me.
Right? What's another analogy other than it rejects its food because it's too picky? See, because usually the thing which is confusing here is usually in, you know, functional based programming functions, you just, you have a function, you feed it something, it just does its thing, right? So this is a very weird case where it is symbolically rejecting it somehow.
Right? It's. It's enter, it's anorexic of F.
I mean, but really the thing is.
It spits it out if it doesn't like.
It. I mean, the thing is, I think most in. Right. I mean, two things. I mean, the first thing is that most kind of, well, I don't know, most quote unquote clean functions will already do this in the sense that, you know, if a function's really been thought through, it'll know what to do when you give it a missing. I mean, of course that's not true of user defined functions and in reality it's not true of a lot of system functions also.
But. Right, and, and I, I for one don't agree that it's obvious that, you know, missing plus missing equals missing.
Right? Yeah, it's not.
Obvious. Right. Although this is supposed to. This will hopefully get rid of some of those situations. But.
Yeah, I mean, apart from the fact that it's too long and doesn't really apply to all the right cases and has weird words in it, maybe missing, protected seems like a not totally ridiculous thing to have in a, in a chain here. And if I had this and.
It says except it's not missing. I know it's failure, but yeah. Megan, this is kind of similar to the discussions we had about confirm, right? Where confirm was the conclusion of the, you know, how do you say something that's kind of.
Correct? Yes, I see what you're saying. I mean, confirm just does. It's a no op if it's.
Correct. Right. I mean, so you would call this something like confirmed applied or something like that. Again, though, I am generally skeptical of calling things confirmed that aren't confirmed because it makes it sound like, oh, this is something that needs to be inside of an enclose when it's.
Not. Right. But confirm is a word that has this feature that it's perfectly okay for it to be A no op, because that's what this needs as.
Well, Maybe.
Validated. But one of the, one of the ones I can see on the JIRA ticket was called conditional applied. I don't know if we have that.
Above. I think that's totally weird because it's, it's a. See, it's not the F that is confirmed or checked or.
Whatever.
Right.
Right. Which is, which is why I was such. Suggesting like validated apply because it's the application that's validated, not the F.
Itself.
Yeah, although I agree that's a bit of a.
Mouthful. Okay, what would it be? It would be like input validated of F. But when anybody figure out what is actually going on there. In other words, what does.
It. I mean, that is to me much more comprehensible than test applied and many of the other, you know, names. Because I'm like, okay, right. I've done something to change how it handles its inputs. Right, that, that makes.
Sense. Input validated. Yeah, but what about validated on its.
Own? It's a little confusing because it is very synonymous with confirm.
Right. And, and obviously the thing that's. It's not the, it's not the thing inside of there that's being validated. So it's. That's potential, you know, potential source of.
Confusion. Yes. Okay, well, so input validators are least crazy, but it's too long. So let's see how we reduce this poetically from two words to.
Less. Yeah, I mean, I, honestly I, I still am a fan of the things that were like on such and such, but.
Yeah. How about pre.
Validate again though, it makes it sound like you're validating the function, not.
The. I'm making the connection between, you know, dollar pre and the fact that this operates on inputs. Maybe that's a suggestion that only makes sense to.
Me.
It. Okay, so let's think of some, Some cases of this. Okay. In the world of, of whimsical cases is a stupid case. Right? You know, you have flow of water through a pipe and you put a grate to prevent, you know, fish coming from the, from the river. I mean, I admit that's a pretty stupid case, but what is the. What would you call that kind of. I'm sure there's some generic word for.
That.
Great. But yeah, I mean, I would call that.
Guarded. Yes, that's it. That's an interesting.
Word.
Filtered. That's not a bad word.
Either. Oh, I like that because it's. I mean, again, I suppose there's the potential ambiguity of. Are you filtering the F or the input. But. And the F is the thing you see.
But.
Right. Another problem is filter. Filter, but select.
But. Yeah, yeah, I agree. I agree. Okay. There's sieved. Sieve.
Purified, by the way. Just guarded was another idea for Configuration.
Firm. I remember a long time ago. Yeah. I've started using. I gave up finally on using an actual sort of physical thesaurus. And I've now started using various websites of which one of the more amusing ones is this related words.
Website. I'm not familiar with.
This. I've seen this.
Yeah.
Gated.
Huh? That's an interesting.
One.
Yeah. Babysat.
Wary. Kind of like.
Wary. Scared. Scared of.
F.
Okay. There's some interesting ones here. Fenced, Barricaded. Well, not so.
Silly.
But I mean, I, I, you know, fenced is not crazy in my.
Opinion. Yeah. But I think something in that. That.
General, like heavily fortified.
Something. Well, it's only fenced. It's not. It's not heavily fortified.
Right. But defended.
Fortified. Check posted. Right. There's a. There's a check. Really? This is adding a check.
Post. Yes. I mean, is F in some way strict? No, I mean, it's not, you know, accepting things.
Loosely.
It's. Well, in the sense. Yeah, in a sense. In the sense, F is dumb. So, you know, I guess we.
Could. I like these. I like terms like this fenced or something. It's not quite right, but something like.
That.
Right. But I think this, this is the. I mean, if you imagine it in a composition chain, what. What do you think it means? I mean, again, this is why I like the. On blank ones. Because it's very clear what it means in a, you know, composition. Shame. Right. I mean, the extreme of that. So the most extreme, and I think this is bad. Is the rust, you know, and then. And so on. Where it's like, this is supposed to be. If you're reading your code and you hit this in a chain of composition that you say the word and then blah, blah, blah. Which I think that's. That's too much. But I think if it's a little bit of that can. Can be.
Okay.
Qualified. It has a degree or.
Something. Yeah. I think there's something in the fence. Barricade, not stockade. Caged.
Enclosed. Well, that's.
Taken. Oh.
Yes. I don't know. I think, I think the prison words I think are all kind of niche. I don't.
Know. But I understand. But, But I think. I think it in. It's fenced for its.
Protection. For some reason, these closed Metaphors seem strange to me. And open metaphors make more.
Sense.
Like. Like things pass through. Won't get choked up on a.
Missing.
Okay. The identity on missing operation or on missing.
Expressions. Okay. So that's what's. Okay, let me try a completely different category. Something like that. That's not right, but it has an.
Override. Talk about sort of short circuiting if you give it something it doesn't.
Understand.
Right. Fail.
Safe. That's not a terrible.
Word. That's not bad.
Yeah, that's actually pretty.
Good. The S lowercase, I.
Think. And. Well, let me check. Miriam Webster, but I'm pretty sure it's one.
Word. Okay. Online it first shows up with a hyphen, but then I think also as.
It'S. I'm sure it's smooshed. Fail safe is.
Good. Says it's.
Dash. Tough.
Luck.
Okay. That which dashes smooshes. Think.
Website Wiktionary also has it as one word. They have it as both.
So. So one word is the direction it's.
Going.
Always. Yeah, that really is true. Over and over again. That happens all kinds of. With all kinds of.
Words. Can you think of any that go the other way? I can't.
No. I mean, I can think of some where there's resistance for a long time. You know, a lot of ambiguity. And cell phone, one word versus two, for example.
Still. Yeah. Well, I mean, there's things like re evaluate where it starts looking very weird. There must be ones where you have triple letters if you smoo. Failsafe is quite good. Definitely the best we've had. It's really quite good. I.
Think so in a chain you'd have it like, you know, fail safe of divide comma, hash, not is not zero or something like.
That. I mean, we'd say fail safe. I like this. This.
Is.
Okay. I mean, this is really.
Quite. Yeah, No, I think this.
Works. Naming is hard test applied to fail safe is not a trivial transformation. Okay. Is there any.
Other. There there. I mean, there were a couple of minor points worth.
Pointing. Yeah. Okay, let's look at this. Okay. I like the name fail safe. Okay. So the way the description would be makes. Fail safe of F applies F to expa in a fail safe.
Way. That's not a good usage.
Line. Giving F. It doesn't really matter. I'm just making it up to see that the sentence works. Giving f of exper if expert is not considered a failure. Blah, blah, blah, blah, blah. All right, let's look at the other cases here. Because this name may inform the other cases as.
Well. Yeah. Okay, so the main question is. Right, so I think the two questions that sort of. Okay, there's the should it support varargs and if it does, what is the test applied to? So one version would be the test gets applied to every argument individually. So you could write something like missing Q and it would check if any arguments are missing. The other version, which based on some experiments I think makes a lot more sense, is the version here where it's the test gets applied in a varargs way to all the arguments. And that way you can do the hash two is not zero.
Case. And so this is this case fail safe of F of X, Y, Z. That's the case you're.
Considering?
Yeah, well, I mean, clearly the default has to be. If any are missing, the hell do you give? I mean, in other words, the.
Default one checks if any of them are missing. And if any of them are missing, it returns the first one that's missing. Which I think makes. Makes sense. But the question is more about if you give a general second argument, what should it do? Because I can't think of anything else reasonable it would do on.
The. Okay, so the question is. Okay, okay. The first thing that's a little bit arbitrary here is if fail safe fails on Z that it returns the failed.
Z.
Yes. Let's just remind ourselves the term failsafe, I think it was invented. Was it a Cold War term? I mean, was that where it was invented or was it invented long before that with trains or something? I just, I'm just trying to.
Remember what the first known use.
1931. There's the fail safe point, which is a Cold War.
Thing. Yeah, right, right, right, right. It says here causing keys machinery to revert to a safe condition in the event of a breakdown or malfunction. It's a great word. It's a great name for this, for this functionality. See, the problem is in a chain here because this isn't really okay, inserting this vararg's form. Is there a curried way that you would insert that Verox form? Because normally the reversion to a safe condition will only work when there's a single thing that you're passing through. It's not clear what in a I. Okay, I would slightly make the argument that we should not have this work right now for the multi. For the vararg's case. And here's why, because I think we're going to have a more sophisticated version as we get these string diagrams and other forms of kind of functions returning more than one thing multis and all that kind of stuff. I have this feeling we might want something more sophisticated for.
This. I mean, I would argue if a function returns more than one thing, the next function is still going to get it as n arguments. Right? I mean like we already do have a way of functions receiving multiple.
Arguments. Yes, we just don't have a way of functions returning multiple.
Arguments. Well, we do if you're. If the way you compose things is using apply but.
Yes, Right, well okay, so let's consider the case where it's an arbitrary.
Test. Yeah, right. That's what they're going to say. So I mean even if, even if we decide that it's too arbitrary and there's nothing to do in the what argument case I would still argue the hash is not equal to zero example is useful enough that it's worth still supporting a varog's version when you have an explicit test. Right, so we could have it so it only accepts a single arg if you don't give it a test but if you give it a test, it's.
Vergs. Well, I'm going to give you an argument for. Okay, here's, here's a question. If it's ferrogs, if the test is fed verogs, how do you determine Gosh, do we not have a way to do this in a function with hash hash and so on how do you determine the number of arguments it's.
Given? Length of list of hash.
Hash. Oh yeah, yeah, right right, right, right. That's.
Fine I guess Length of hold complete of hash hash because you don't know if your function has attributed but yes, That's.
Pedantry. So yeah, right. Seems reasonable to me. I agree with you that the case all right, so the only thing that is bothering me as arbitrary is this business about return the first one that you know what so what is the default.
Test? Oh actually so.
Sorry. So.
There'S. There's a third argument that's relevant for the return thing. So there's a third argument which I think should also be varargs. It should also take the exact same arguments as the first two and this is what you what you run and return if you. If it.
Fails. Right so actually if you. If you scroll up to my bullet points, I I have a couple of comments about the the. The. Those additional.
Arguments.
Right right. So right now the Right. The second argument currently acts as a supplement rather than a replacement for.
The. No, I think it acts as a replacement then pretty sure it should. It should be a replacement. If it isn't, then it should.
Be, oh, is it missing? Is it that missing? Does missing of missing turn into missing? Is that why. It would confuse me because that example there seems to suggest.
That. Oh, the one with the. Well, which.
One? So.
The. Oh, positive returns false on missing, if that's what you mean. I think. I think that's the. Or it's checking true Q. So positive of missing probably does not return true Q. Oh, that's what confused. But yes, you're right. That example is a little bit broken.
Now. Okay. Oh, so wait a minute. What was the point? The point is.
That. That the question is, is it still going to fail? Is the test replacing the test the checks for failure are missing? Or is the test that checks.
For failure missing always.
There. It should replace.
It. Yeah, it should just replace.
It. Right, but the default third argument was sort of confusing the issue. Right? Because Notice that the -10 turns into a failure object, but the missing just turns into a.
Missing. Okay, could somebody tell me what is the defaul.
Test? Sorry, that missing there. That missing there did. All right, never mind. Okay.
Yeah. I mean, because the default test would normally be failure queue, but it isn't if it's.
Ver. Well, it's not. Well, it's not failure queue either. Right, right. It's actually like any true of list of hash, hash comma, failure Q but not failure cube. It's more bigger than that. But yeah, you can look at. The code is like 10 lines long for this. You can just open the pod if you want to see it. Right. And then there's also automatic behavior for taking, you know, for. For the third argument for taking all.
For.
For. Basically, if you use the default test, the third argument is basically just going to say, find me the first thing that failed the test and return that. And if you're using anything other than the default test, then the third argument wraps everything in a big failure.
Object. You know, Atom on our livestream is making an interesting suggestion. They say fail safe should return the preceding term and fail fatal should halt execution. Fail none should return empty or null object. We don't really quite have a null object. Well, of course, but here, in a sense, what we would have here is fail.
Safe.
Fail. I mean, we already have many mechanisms to halt.
Execution. Right. That. That would just be.
Confirmed.
Right. We still don't actually. We still haven't really done anything with untagged, unenclosed confirms, but that is a potential.
Behavior. It's even not clear where you return to. I mean.
We. Yeah, I know, I know. It's some return to the top level, quote unquote. Top.
Level. Right, okay. But anyway, so. So we're back to. All right, so I'm just a little concerned. Okay, so the second argument, you know, it will be easy to have a bug where you didn't consider the Vero's case and you just gave a name here and you didn't say of hash1. You see what I'm.
Saying? Right? Yeah.
Yeah. I mean that would be an easy thing to. I mean it's a nice code assistance thing to check for, but. Okay.
So you've got that would. The thing is, I think there, it's a little bit of.
A.
There. There are two kinds of errors. There are errors that you know happen and there are errors that you don't know happen. So there are errors where it's like, well, I'm going over this list. I know the list contains missing, so I need to handle them. In which case, I think the danger of oh, whoops, I applied it to 10 arguments isn't really a problem because we're sort of assuming, you know, the failures are and you're targeting known failures. That's as opposed to the case of the, you know, I don't know where the failures are, but I'm going to try and bulletproof my code. In which case, yes, it will be a problem if you, you.
Know.
That would be an.
Issue. I think we've got a winner here. I think we pretty much know what this has to do. I think Test fun is overrides anything else and is Verog's fail fun. Similarly, the default fail fun is return the first.
Failure. Right. Although other than then, oh, that's.
Not going to work because test fund. Hold on, that's not going to.
Work. I know, I.
Know.
Yeah. Right. So if, if you're using the automatic test fund, I would argue it should be the first failure because that is fine. But if you're useful, if it returns something directly, fine.
Yeah. Non automatic test fun. What does it.
Do? I think it returns a.
Failure. I see a manufactured.
Failure. Right. And you can see that's what it did here. So you see in the first example, you know, the missing not available just returned immediately. Otherwise he gave his.
Failure. And by the way, are.
We. Sorry, I. Sorry, I was muted. I. Right. I was, I was surprised by, by the fact that the Right. That the missing came through as missing, but the -10 came through as a failure.
Object. Well, I think it's Because. Right. It's because there's a test, an explicit test.
Given. Right?
Yes.
Right. So, so, so, Right. So it's not that it's not. Right. I misunderstood what was happening. But, you know, now that I understand, I. I will just reiterate that it is potentially confusing that the default thing. Well, you know, give.
You.
Miss. I. I expected, you know, either both the failure objects or, you know, a missing and a minus 10 there. I know maybe a minus 10 doesn't make.
Sense. Hold on. Why does it give.
Us. Yeah, so I just looked at the code. So actually what the current implementation does is a bit weirder. Right. Than what I was saying. The current implementation just looks at the arguments. If any of the arguments are obviously failures, as in failure queue, missing, et cetera, as in will be triggered by the default test, then it just picks the first one of those and returns that. If none of them are obvious failures, then it wraps a failure object. Right. So I think probably would be better if it just. It just always. If you give it a test, it'll always do a failure object. And if you don't give it a test, it'll always just pick the first.
One. I think that's.
Right. Yeah. I'm okay with.
That. Okay. All right. We got a good name for this. This is a good name. The.
Okay, I would like to propose that we end here because, you know, it's 5:35 and I. I don't think the echo thing is going to be a short.
Conversation. Just open it up and just see if it could be a short conversation. If it's not, I agree with the.
End. Given the amount of.
Text. Yeah, it's an important conversation, but I.
Agree. Right. I'm perfectly happy to start this at the next LCC meeting, assuming nothing super urgent comes. Comes up. But, you know, I. I'm just saying, I. I would rather not start. All.
Right. Maybe we should just quit while we're ahead because we got a good name. Yep. Okay. Sounds good. Well, that's. Happy holidays, everybody. And if I don't see you all before then. See you.
Later. Bye.
More from Guy

Cheryl Strauss Einhorn | The Human Edge: Smarter Decisions in the Age of AI | Talks at Google

Rachel Glennerster | Innovation and the Center for Global Development | Talks at Google

Rebecca Winthrop | Rethinking the Purpose of Education in the Age of AI | Talks at Google

Dr. Robert Wachter | A Giant Leap: How AI Is Transforming Healthcare... | Talks at Google






