[e-lang] File API taming

ihab.awad at gmail.com ihab.awad at gmail.com
Thu Mar 19 21:07:40 EDT 2009


On Thu, Mar 19, 2009 at 5:31 PM, Kevin Reid <kpreid at mac.com> wrote:
> Insofar as this is part of The Web, perhaps we should (pretend, if
> necessary) that files have MIME types, er, media types? Namely, have
> "media type" be a visible attribute of a file object, even if in
> implementation it results from its name extension inside the parent
> directory?

Agreed. So given a directory 'd', the operation --

  var f = d.get('foo.txt')

returns a file that answers to --

  f.getMediaType()

which may either be initialized by the directory 'd' upon creation,
based on the file name, or it may be an intrinsic property of the file
in some other way.

The asymmetry, however, is that *asking* a file to change its own
media type is no longer the same: In one case, the file itself has
that authority; and in the other case, the file has to consult its
directory saying, "please rename me from 'foo.txt' to 'foo.doc'".

That said, the directory 'd' could, if desired, initialize 'f' with a
function that closes over  'd' and does the renaming, without giving
'f' direct access to 'd'.

Does that sound reasonable?

Ihab

-- 
Ihab A.B. Awad, Palo Alto, CA


More information about the e-lang mailing list