Twenty five thousand dollars of funny money
rachelbythebay.com
Twenty five thousand dollars of funny money
1–10 of 175 posts
Re: Twenty five thousand dollars of funny money
#2Re: Twenty five thousand dollars of funny money
#3Re: Twenty five thousand dollars of funny money
#4Scalars like this are so dangerous. A New Type would help here, but this is much easier to say in hindsight.
Re: Twenty five thousand dollars of funny money
#5In Racket, I tended to use keyword arguments, and include the units in the keyword argument. For example, one library used `:velocity-mm/s`. (The `/` character is an identifier constituent, not some special operator syntax.)
In Rust, I'm going to try out using language features for static checking of some units (with 0 runtime cost).
Re: Twenty five thousand dollars of funny money
#6Re: Twenty five thousand dollars of funny money
#7But I still wish I could say “this function accepts a type called RobotName. It’s a string, but so is RobotUuid, and we don’t want that. So only accept, strictly, objects typed as RobotName.”
Re: Twenty five thousand dollars of funny money
#8I'm confused how this was able to give out money before the new code was submitted to production. The author claims that both she and her coworker tested it before the code was submitted and they ended up with the extra $25k. Was this code only executed on the front end? Were there no checks in the backend to prevent employees from just pulling out whatever money they wanted?
So yeah I’m curious how that worked too.
Re: Twenty five thousand dollars of funny money
#9I think I like the duck typing in TypeScript more than I dislike it. But I still wish I could say “this function accepts a type called RobotName. It’s a string, but so is RobotUuid, and we don’t want that. So only accept, strictly, objects typed as RobotName.”
function foo(r: RobotName) {}
?
Re: Twenty five thousand dollars of funny money
#10I think I like the duck typing in TypeScript more than I dislike it. But I still wish I could say “this function accepts a type called RobotName. It’s a string, but so is RobotUuid, and we don’t want that. So only accept, strictly, objects typed as RobotName.”
interface RobotName {
value: string;
type: "RobotName";
}
Or if you don't want to make an extra wrapper around every object: interface RobotName {
_phantomType: "RobotName";
}
function makeRobotName(name: string): RobotName {
return name as any as RobotName;
}
function getRobotName(robotName: RobotName): string {
return robotName as any as string;
}
Presumably V8 is smart enough to inline the wrapper functions.