[Swift-devel] "type file;" by default
Michael Wilde
wilde at mcs.anl.gov
Wed Feb 4 07:49:12 CST 2009
I'm in favor of making "file" a built-in type.
I further propose we then use the term "file type" instead of "marker"
or "mapped" type.
It seems there are at least 2 ways to do so, subtly different:
(a) as if the statement "type file;" has been implicitly executed, or
(b) as if there is a new simple, built-in, mapped type called "file".
(b) seems a bit better, because then the currently unnamed, built-in
"marker" type gets a name.
If we use alternative (a) above, you would still say:
type Image;
file f;
Image i;
Here, nothing changes except for the built-in definition for "file" -
not how you *use* the word "file".
With alternative (b), though, you would say:
type Image file;
file f;
Image i;
We could still allow the old style declarations to remain valid (but
deprecated) for now (or forever), to avoid impact to existing code.
I favor approach (b), because it gives the un-named "marker" type, and
hence all primitive built-in types, an explicit name. And it looks less
quirky. But its a minor point.
- Mike
On 2/3/09 5:45 AM, Ben Clifford wrote:
> Pretty much every simple SwiftScript program that I write, I find myself
> putting in "type file;" at the start, and avoiding "marker types" of the
> form:
>
> type picturefile;
>
> and thus ignoring application-level type checking (checking that I'm not
> feeding a picture into a text processing app, and the like) whilst still
> taking advantage of other swift type checking.
>
> To simplify low-end uses of the language, it might be useful to have the
> above "type file;" defined as a built-in type.
>
> This has been discussed before, but I'd like to know what peoples opinions
> are.
>
More information about the Swift-devel
mailing list