all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Eli Zaretskii <eliz@gnu.org>
To: Stefan Monnier <monnier@iro.umontreal.ca>
Cc: cyd@stupidchicken.com, raeburn@raeburn.org, sdl.web@gmail.com,
	emacs-devel@gnu.org
Subject: Re: Should Emacs provide a uuid function?
Date: Mon, 09 May 2011 22:32:29 +0300	[thread overview]
Message-ID: <838vufisaa.fsf@gnu.org> (raw)
In-Reply-To: <jwv62pjdd14.fsf-monnier+emacs@gnu.org>

> From: Stefan Monnier <monnier@iro.umontreal.ca>
> Cc: cyd@stupidchicken.com,  raeburn@raeburn.org,  sdl.web@gmail.com,  emacs-devel@gnu.org
> Date: Mon, 09 May 2011 14:03:44 -0300
> 
> >   (defcustom battery-status-function
> >     (cond ((and (eq system-type 'gnu/linux)
> > 		(file-readable-p "/proc/apm"))
> > 	   'battery-linux-proc-apm)
> > 	  ((and (eq system-type 'gnu/linux)
> > 		(file-directory-p "/proc/acpi/battery"))
> > 	   'battery-linux-proc-acpi)
> > 	  ((and (eq system-type 'gnu/linux)
> > 		(file-directory-p "/sys/class/power_supply/")
> > 		(directory-files "/sys/class/power_supply/" nil "BAT[0-9]$"))
> > 	   'battery-linux-sysfs)
> > 	  ((and (eq system-type 'darwin)
> > 		(condition-case nil
> > 		    (with-temp-buffer
> > 		      (and (eq (call-process "pmset" nil t nil "-g" "ps") 0)
> > 			   (> (buffer-size) 0)))
> > 		  (error nil)))
> > 	   'battery-pmset)
> > 	  ((eq system-type 'windows-nt)
> > 	   'w32-battery-status))
> 
> I don't mind this kind of dispatch table, personally.
> 
> > I think it would be much cleaner to have 5 different implementations
> > in sysdep.c of the same primitive, than have the above followed by 4
> > different Lisp functions plus one primitive.
> 
> I don't find the dispatch table worse than the sysdep.c
> code, personally.

FWIW, I'm very surprised to hear this from you.

I understand the motivation to move to Lisp everything that can be
moved, especially if the code deals with Lisp data types, but there
should be limits, I think.  Lisp is not suited well to reading raw
data from files and device drivers.  insert-file-contents is a much
higher abstraction than `read' and `fscanf'.

It's not a coincidence that battery.el's implementation of these 4
functions take at least twice as much code as a C version would.
Worse, a programmer who wants to change battery.el now needs to
understand how the OS stores the data on those special files, which is
something most Lisp programmers don't and shouldn't care about.

Such code is okay in one's ~/.emacs, but not in a bundled package.

It is much better, IMO, to have the low-level stuff in a language that
was designed for that, and present to Lisp lispy data types and
structures that are as platform independent as possible.



  reply	other threads:[~2011-05-09 19:32 UTC|newest]

Thread overview: 47+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-04-15  4:59 Should Emacs provide a uuid function? Leo
2011-04-24 20:43 ` Chong Yidong
2011-04-25  3:37   ` Leo
2011-04-25  4:37     ` Stephen J. Turnbull
2011-04-25  7:21       ` Ken Raeburn
2011-04-25  8:45         ` Stephen J. Turnbull
2011-04-25  9:53           ` Eli Zaretskii
2011-04-25 10:33             ` Stephen J. Turnbull
2011-04-25 12:30               ` Eli Zaretskii
2011-04-28 15:11           ` Ken Raeburn
2011-04-29  3:47             ` Stephen J. Turnbull
2011-04-30  8:00               ` Ken Raeburn
2011-04-30 18:39                 ` Stephen J. Turnbull
2011-04-30 22:22                   ` Ken Raeburn
2011-05-01  9:06                     ` Stephen J. Turnbull
2011-04-30 13:32               ` Richard Stallman
2011-04-30 13:39                 ` Eli Zaretskii
2011-04-25 19:52         ` Chong Yidong
2011-04-28 15:11           ` Ken Raeburn
2011-05-09  6:29           ` Leo
2011-05-09  7:23             ` Eli Zaretskii
2011-05-09 10:51               ` Ted Zlatanov
2011-05-09 11:35                 ` Eli Zaretskii
2011-05-09 11:36                 ` Leo
2011-05-09 14:38               ` Stefan Monnier
2011-05-09 14:51                 ` Eli Zaretskii
2011-05-09 15:41                   ` Stefan Monnier
2011-05-09 15:50                     ` Eli Zaretskii
2011-05-09 17:03                       ` Stefan Monnier
2011-05-09 19:32                         ` Eli Zaretskii [this message]
2011-05-09 15:09                 ` Chong Yidong
2011-05-09 15:26                   ` Eli Zaretskii
2011-05-09 15:27                   ` Ted Zlatanov
2011-05-09 15:36                     ` Eli Zaretskii
2011-05-09 15:42                       ` Ted Zlatanov
2011-05-09 15:53                         ` Lars Magne Ingebrigtsen
2011-05-09 15:51                   ` Stefan Monnier
2011-05-09 15:59                     ` Lars Magne Ingebrigtsen
2011-05-09 17:05                       ` Stefan Monnier
2011-05-09 17:45                     ` joakim
2011-05-09 17:50                       ` Lars Magne Ingebrigtsen
2011-05-10 14:03                         ` Jason Rumney
2011-05-30 17:22                           ` Lars Magne Ingebrigtsen
  -- strict thread matches above, loose matches on Subject: below --
2011-04-26 21:06 Ben Key
2011-04-26 21:16 Ben Key
2011-04-26 22:51 ` Chong Yidong
2011-04-27  3:43   ` Leo

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=838vufisaa.fsf@gnu.org \
    --to=eliz@gnu.org \
    --cc=cyd@stupidchicken.com \
    --cc=emacs-devel@gnu.org \
    --cc=monnier@iro.umontreal.ca \
    --cc=raeburn@raeburn.org \
    --cc=sdl.web@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.