bug-hurd
[Top][All Lists]
Advanced

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

Interfaces (was: Hurdish TCP stack)


From: olafBuddenhagen
Subject: Interfaces (was: Hurdish TCP stack)
Date: Fri, 4 Apr 2008 10:10:44 +0200
User-agent: Mutt/1.5.17+20080114 (2008-01-14)

Hi,

On Thu, Apr 03, 2008 at 05:52:49PM +0200, Ludovic Courtès wrote:
> <olafBuddenhagen@gmx.net> writes:

> > Actually, most people will consider it easier to use it from a C program
> > as well: For one, it means that you can use the *same* knowledge for
> > doing stuff on the shell, and for writing C programs. That's a very
> > valuable property IMHO.
> 
> Isn't it easier to write:
> 
>   port = hurd_file_name_lookup ("/stuff", ...);
>   do_foo (port);
> 
> than:
> 
>   int fd;
> 
>   fd = open ("/stuff/ctl", ...);
>   if (fd < 0)
>     ...
>   count = write (fd, "do_foo", 6);
>   if (count < 6)
>     ...
>   close (fd);

Depends on what you mean by "easier". If you only look at the amount and
elegance of code, obviously it is simpler. But if the shorter variant
requires lot more learning to write, about the specific RPC interface
involved -- and if someone is new to Hurd programming, also the
fundamentals of ports and RPCs -- then many people will actually
consider the longer variant easier to write. I for my part would for
sure...

> Of course, you could provide the latter as a `do_foo ()' function in
> the library, but then, you'd pay the overhead for the textual
> representation without even seeing it.

Actually, the right approach is:

   file_set_contents("/stuff/ctl", "do_foo")
   
(Unfortunately libc doesn't provide this function; but that should not
be a major problem...) Even simpler than the RPC variant. Exposes the
textual representation, without the ugly details of file handling.

-antrik-




reply via email to

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