POV: You are a compiler targeting arm64, and you want some code to reference this global variable from the same library. The classic way to do this is to emit an instruction that loads “the address of X”, which will be determined at run time by the dynamic loader. But that’s not super efficient! For one thing, addresses are 64 bits long, and instructions are only 32 bits, so you can either break it up into multiple instructions, or load the address from some other location. But more importantly, the global variable is in the same library. The dynamic loader isn’t going to break it up from this code, and if we knew how far away it was we could reference it that way.
That’s what the
adrp instruction’s for.
This post is in response to Aria Beingessner’s “Defaults Affect Inference in Rust: Expressions Instead Of Types”, which describes how adding default arguments to Rust could help with some Rust stdlib problems around generics. At the same time, the Rust internals forum has a thread on “Named Arguments” something that’s been discussed for Rust off and on for years (at varying levels of seriousness).
Here I’m going to discuss how those two features interact, and why considering them separately is potentially a bad idea. It’s a lot more braindump-y than my usual style, so be warned. The post is written with a Rust audience in mind, but makes frequent reference to Swift, Python, and C# as examples of real-world languages that have some version of these features. It also overlaps quite a bit with Aria’s post.
In the general interest of pay transparency, here’s a table showing how much I made at Apple (a Big Company that’s nonetheless not known for particularly high compensation in the tech industry), vs Signal (a nonprofit that nonetheless understands that it has to be in Tech Salary Range to be competitive).
(Why “#TalkPay”? It’s a Twitter hashtag that seems to have originally come from 2013’s conversation around the gender wage gap…but I first heard it in the context of openly sharing your name, location, role, and salary, so that others in similar positions could check if they were being paid a fair amount. Lauren Voswinkel, who put out the original call for action in 2015, has a good rundown.)