emacs-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: master 1e3b0f2: Improve doc strings of project.el


From: Eli Zaretskii
Subject: Re: master 1e3b0f2: Improve doc strings of project.el
Date: Sat, 18 Jul 2020 13:10:24 +0300

> Date: Sat, 18 Jul 2020 11:05:46 +0200
> From: tomas@tuxteam.de
> Cc: emacs-devel@gnu.org
> 
> > I could be wrong in some details here, but a file descriptor seems
> > like a prime example of an abstraction.
> 
> Well, that's at the Mother of Abstraction, aka the user space/kernel
> space barrier :-)

IMO, there's nothing opaque about a file descriptor.  It is just a
number.  The abstraction here isn't in the descriptor itself, it's in
what it _represents_.  The descriptor is actually a _handle_ for an
object that itself is not exposed at all; you can only manipulate it
via the handle.

> Yes, this is some kind of OO. But it leaks a couple of things:
> first, it's a "small number" (i.e. not some random 64 bit
> address, but the pattern of counting up from zero and of building
> bitmaps of FDs is considered --mostly-- viable), i.e. the mental
> model around is that the kernel "has" a table somewhere indexed
> by FD. This detail wasn't probably intended to leak in the first
> place, but was just "the obvious thing to do" in a world in which
> machines with a 32 bit address space were considered serious iron.

That detail is not a general trait of a handle.  Another popular
example of a handle is a FILE pointer in C, where the details of the
object it points to are generally not public.  Here, the numerical
value of the handle is no longer small.

Yet another similar abstraction, much more close to our domain, is the
Lisp_Object representation on the C level: with a couple of
exceptions, each object is actually a handle of a C struct; once
again, the value is not necessarily small, especially if the object
tags use the MSBs.  Sometimes, very rarely, these handles are even
exposed to Lisp; one example is file-notify--add-watch-* functions.

So I think the handle notion and the related design patterns are only
tangentially relevant to the issue at hand.

P.S. The interpretation of a file descriptor as an index into some
small table doesn't hold in modern OSes anyway.  It was true for
MS-DOS, but modern OSes have moved away of that.

P.P.S. And no, not everything in C is a number, unless one also holds
that "everything in computing is a number".



reply via email to

[Prev in Thread] Current Thread [Next in Thread]