If you have the expression 1+2*3 you have three elements with two operands. You need to choose a rule to pick one of them first.
In mathematics, the rule is "*/ then +-" and then from left to right. This means that usually first you do 2*3, then 1+.
But what if you do want to make 1+2 first?
There is another alternative, parenthesis. Those mean "do the thing inside first" so (1+2)*3 changes the precedence and now you do 1+2 first, then *3
The post is asking: with parenthesis you can increase the precedence of operations. What if you could decrease it?
Let's use «» as another operand (the blog uses parenthesis, but that makes it really confusing) this operand means "do the thing inside last". So the expression 1+«2*3» means "do 1+ first, then 2*3.
The issue is...this doesn't make sense, what the blog is really saying is to reduce the precedence of operators. Think the expression 1+2«*»3 or 1+2(*)3 and now the rule is "the parenthesized operators have one precedence less" so 1+2(*)3=(1+2)*3
Thank you. I thought I was going crazy reading the article which doesn’t connect open and close parenthesis :: higher and lower precedence :: indent and outdent :: +1 and -1 and just flip it around to get the opposing polarity.
This seems to be the best guess so far. But then I am wondering, how is
a (*) b + c
Parsed then? The precedence of '* is bumped down, but does that mean it has now strictly lower precedence of '+', or the same? In the first case the operation is parsed as
a * (b + c)
In the second case, the "left to right" rule takes over and we get
(a * b) + c
And what happens when there are more than 2 priority groups Taking C has an example, we have that '' has higher precedence than '+' which has higher precedence than '<<' [1]. So
a + b * c << d
Means
(a + (b * c)) << d
Now I could use the "decrease precedence" operator you proposed (possibly proposed by the author?) and write
a + b (*) c << d
Which then bumps down the precedence of '' to... One level lower? Which means the same level of '+', or a level lower, i.e. a new precedence level between '+' and '<<'? Or maybe this operator should end up at the bottom of the precedence rank, i.e. lower than ','?
The more I think about this, the less sense it makes...
I don't think that's even well-defined if you have arbitrary infix operators with arbitrary precedence and arbitrary associativity (think Haskell).
If $, & and @ are operators in that order of precedence, all right-associatve. Using your notation, what is:
a & << b $ c >> @ d
If $ is reduced below & but above @ then it's the same as:
((a & b) $ c) @ d
If it's reduced below both & and @ then it becomes:
(a & b) $ (c @ d)
I think conceptualizing parentheses as "increase priority" is fundamentally not the correct abstraction, it's school brain in a way. They are a way to specify an arbitrary tree of expressions, and in that sense they're complete.
Thanks indeed.
Using a simple left-to-right evaluation is the most logical solution.
You can reorder expressions to use less parentheses and make them easier to read. E.g.: Smalltalk :-).
But this requires everyone un-learning their primary school maths of e.g. multiply-before-add, so it's not popular.
Having hand-picked operator precedences complicates things further when you allow operator overloading and user defined operators. E.g. Swift has special keywords to specify precedence for these. Ick...
Thanks, writing it as 1+2(*)3 made it click for me.
Reminds me of the '$' operator in Haskell - it lowers the precedence of function application, basically being an opening parenthesis that's implicitly closed at the end of the line.
well I'll be that guy... If you're going to disturb the normal way of righting expressions, RPN or prefix notation (AKA Polish Notation) could be a better option. Both don't need parenthesis because they don't need precedence/priority rules - which are obviously a disadvantage of the infix notation.
The HP 48 famously took the bet of going against the mainstream notation. I wonder to what extent this is one of those "accidents of history".
RPN moreover simplifies parsing, as shown by the Forth language.
Prefix notation, as used by for instance Lisp, doesn't actually need parenthesis either; Lisp uses them because it allows extensions over basic operators and more generally "variadic" operators and functions (e.g. (+ 1 2 3 4)). Without this "fancy" feature, prefix notation is unambiguous as well: / + 1 2 3. [1]
On a side note, Smalltalk is one of the few languages that said "duck it", and require explicit parenthesis instead - which is IMO, not an insane approach when you see that for languages with 17 levels of priority like C, you end up putting parenthesis anyway as soon as the expression is not trivial "just to be sure" (e.g. because it mixes boolean operators, arithmetic operators and relational operators as in a & 0xF < b + 1).
Gerald Jay "Jerry" Sussman from Scheme and SICP fame (and others) would tell you there's also the prefix notation (but ofc only infix makes TFA valid: prefix or postfix makes it mostly moot). "3 x 4 x 7 x 19" only looks natural to us because we've been taught that notation as toddlers (well, ok, as young kids).
But "x 3 4 7 19" is just as valid (Minksy and having to understand someting in five different ways or you don't understand it etc.).
I personally use Google forms for a very similar feature. You don't even need to display the google form itself, you can create your own and then perform a fetch.
I even have it connected to a google sheet and google scripts, to send me emails for entries matching some patterns.
Heavily depends on Google, yes, but for something free that honestly I won't care if stops working (like a prototype) I'm ok with it.
I like icons (and colors, but those are still mostly missing) to quickly find a frequent action. If the menu is always the same you can learn the position, but with dynamic entries it's way more difficult.
If I write actions/setup-python@v1, I'm expecting the action to run with the v1 tag of that repository. If I rerun it, I expect it to run with the v1 tag of that repository...which I'm aware may not be the same if the tag was updated.
If I instead use actions/setup-python@27b31702a0e7fc50959f5ad993c78deac1bdfc29 then I'm expecting the action to run with that specific commit. And if I run it again it will run with the same commit.
So, whether you choose the tag or the commit depends on whether you trust the repository or not, and if you want automatic updates. The option is there...isn't it?
You specifying the top level hash doesn't do anything to pin transitive dependencies, and as the article points out, transitive dependencies - especially dependencies common to a lot of actions - would be the juciest target for a supply chain attack.
> which I'm aware may not be the same if the tag was updated.
That's the mistake that breaks the following. People don't usually expect that it's an arbitrary modifiable reference, but instead that it's the same version they've picked when they created the file (ie a tag is just a human friendly name for a commit)
On play store you can see the permissions that an app uses and they are grouped by category. Have full network access is set in the "others" category, same as notifications and vibration. This is a category where (supposedly) permissions are automatically granted.
But to be honest, other similar dangerous permissions like "view network connections" and "receive data from internet" are also there, categories are for "camera", "microphone" etc.
I suppose that the average user is more concerned about specific features, and since basically almost all apps require internet it may be there to avoid noise.
Still, an "internet" category would have been nice...
The reason why internet access/downloading from the internet isn't a "major" permission is that asking about it would let people conveniently disable it for any offline apps with ads in them to remove the ads. Google doesn't like that, obviously. Of course, you can still disable your wifi/mobile data connection entirely, but it has friction that most average consumers won't trouble themselves with. But if the app asked if you wanted to give it internet access on launch, Google's ad revenue would probably be visibly affected.
I've always wondered what would happen with a shop that never has sales. A shop where the prices are always the same, although they may occasionally increase them due to inflation, etc.
Such a shop will not get the surge of "oh look a discount, let me buy it" consumers, but people will probably realize that this way when you need something you can buy it on the spot, and it will always have the best price no matter when.
>I've always wondered what would happen with a shop that never has sales. A shop where the prices are always the same, [...] Does a shop like this exist, or existed?
An ex-Apple executive who ran the Apple retail stores tried that strategy with JC Penney and it didn't work:
It actually was beginning to work. Corners of the internet where people discuss clothing and fashion trends were starting to buzz about JC Penny randomly starting to have trendier higher quality stuff for reasonable prices, etc.
I think they would've needed a another year or two of runway though to turn the ship around and court an entirely new (non-overlapping) customer base, and the investors simply weren't willing to give them that much time.
I don’t know of a shop that doesn’t have some sales at some time. Sales are just such powerful selling tools.
Factorio is a counter example. Factorio never goes on sale, which is kind of nice because when you buy it you know you couldn’t have gotten a better price, but without sales you aren’t as motivated to buy it for a lower price than usual.
Lots of shops run similarly to this in American/canadian/Japanese made men’s fashion. Example stores include Self edge, standard and strange, brave star selvedge, whites and nicks boots, etc only use sales for items that have small defects, were returns, etc.
It’s nice to see brands which refuse to play by fast fashions games and who sell their products based on their quality.
Of course, these brands will often takes weeks or months to get you your item due to the waitlists. You can’t even get on the waitlist for a ship John 24 ox Willis waxed canvas jacket because they’re back ordered 6+ months.
Costco are pretty unobtrusive with their discounts. They have random coupons on things, but only for a small amount. Except, of course, for the famous inflation proofed loss leader $1.50 (£1.50 in the UK) hot dog.
Business oriented stores can run this way. Places like McMaster Carr?
Walmart tried to advertise this for decades as “always low prices” which worked pretty well, but even they have clearance (need to rotate shelf space or excess inventory) and rollbacks (price matching someone somewhere).
They do not have Kohls style “50% off everything if you jump through these hoops”.
rollbacks = raise the price then reduce it and pretend you lowered prices.
clearance = stuff that's been on the shelf for years for barely discounted prices.
Their tech clearances are often ridiculous. Things like 2GB sd cards for $25, marked down from $30 but that $30 price was from 10 years ago when 2GB was considered a large sd card.
That's exactly the point. It has nothing to do with a monopoly - retail is all about cashflow. Walmart has 2.8% net margins, and do it with a maniacal focus on cost control and vendor management.
A manufacturer with a unique product can control pricing and manage demand. The business is the "vertical", they don't live or die with retail. Apple discounts through authorized third parties only. Rolex constrains supply, controls retail price & experience, and generates demand with the secondary market premium. People buy a watch for $15k because it's "worth" $20k. It's inferior as a tool compared to a watch that costs $50, and there's a whole spectrum of fancy watches that don't have the same cachet.
JC Penney doesn't have that. They're stuck with a warehouse full of low-margin pants and need cashflow, so they discount to get cash in, then jack the price up at different part of the demand cycle. Khakis that are $40 for back to school are $75 right now, and coupons are used to keep the cost conscious folks coming.
I'm pretty sure it was done on the first one, Halo CE for the original Xbox. The last times I've played it have been coop in the MCC though which skips that part.
I had the same experience with an android app on play store a few years ago (when LLMs didn't exist yet) so this is nothing new.
As you said, I didn't mind others creating apps with the same idea, the issue is when someone takes your app, decompiles it, injects ads (mine is ad-free) or changes the author name, and publishes it. And I know this was the case because the app was a verbatim copy (except for the ads), bugs included.
At first I sent some DMCA, it usually worked, but not always. If you have time and you are bored do it, but keep in mind that if someone tries to fight back you'll have issues, and at that point you need to consider if your time fighting is worth more than the app itself (on my case the app was free so...no).
What I did learn is that plagiarism is something that some countries accept socially. In these countries taking a successful thing and copying it is seen as a "positive" achievement (like "hey, look, I was able to do the same as this other guy! I'm so smart!"). I understand this mentality, as long as only the idea is copied, but when assets or the whole app is copy/pasted, without giving any credit...yeah that's when you get angry.
Because usually you have an ide that manages imports for you automatically. So unless you are using a library that has multiple imports, usually you know the import to include, and in almost all cases it is automatically included.
Btw: in the compact example! The IO class is implicitly imported, so that example truly works without any import at all!
If you have the expression 1+2*3 you have three elements with two operands. You need to choose a rule to pick one of them first.
In mathematics, the rule is "*/ then +-" and then from left to right. This means that usually first you do 2*3, then 1+.
But what if you do want to make 1+2 first?
There is another alternative, parenthesis. Those mean "do the thing inside first" so (1+2)*3 changes the precedence and now you do 1+2 first, then *3
The post is asking: with parenthesis you can increase the precedence of operations. What if you could decrease it?
Let's use «» as another operand (the blog uses parenthesis, but that makes it really confusing) this operand means "do the thing inside last". So the expression 1+«2*3» means "do 1+ first, then 2*3.
The issue is...this doesn't make sense, what the blog is really saying is to reduce the precedence of operators. Think the expression 1+2«*»3 or 1+2(*)3 and now the rule is "the parenthesized operators have one precedence less" so 1+2(*)3=(1+2)*3
reply