If we add coordinates to the macro language (#243), we run into the problem that, even though it will be possible to convert from a coord to a pad, there will be situations in which we may want to be sure that we are talking about the pad rather than the coord. Similarly, we may want to be sure that we're talking about a pad rather than a drop that can convert to a pad.
Three situations spring to mind:
If you declare a variable with local, the type is inferred from the expression, so you may get a type different from what you expect:
local p = (0, 0);
This isn't so bad with coord and pad, since you will be able to convert in either direction, but if you try it with a drop, you'll get a drop variable, which can't be assigned a pad.
Similarly, if you introduce a variable in an interactive context, you might get the wrong type.
If you try to pass in a parameter to a built-in that's overloaded for coord and pad (or, in the future, when we support overloading (#160)), you may get the wrong one.
built-in-foo((1,1));
You can get around this by assigning to a variable whose type is explicit:
pad p = (1,1)
built-in-foo(p)
but it is probably worthwhile to be able to explicitly cast. The syntax I'm leaning toward is
built-in-foo((1,1) as a pad)
Migrated from internal repository. Originally created by @EvanKirshenbaum on Feb 11, 2023 at 4:55 PM PST.
If we add coordinates to the macro language (#243), we run into the problem that, even though it will be possible to convert from a
coord
to apad
, there will be situations in which we may want to be sure that we are talking about thepad
rather than thecoord
. Similarly, we may want to be sure that we're talking about apad
rather than adrop
that can convert to apad
.Three situations spring to mind:
local
, the type is inferred from the expression, so you may get a type different from what you expect:This isn't so bad with
coord
andpad
, since you will be able to convert in either direction, but if you try it with adrop
, you'll get adrop
variable, which can't be assigned apad
.coord
andpad
(or, in the future, when we support overloading (#160)), you may get the wrong one.You can get around this by assigning to a variable whose type is explicit:
but it is probably worthwhile to be able to explicitly cast. The syntax I'm leaning toward is
Migrated from internal repository. Originally created by @EvanKirshenbaum on Feb 11, 2023 at 4:55 PM PST.