unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
* Re: Return
@ 2010-12-05 23:55 MON KEY
  2010-12-06  1:48 ` Return Stephen J. Turnbull
  0 siblings, 1 reply; 71+ messages in thread
From: MON KEY @ 2010-12-05 23:55 UTC (permalink / raw)
  To: emacs-devel; +Cc: stephen

,----
| Note that Python (at least) has adopted this approach, with a core
| language definition that is 99% or so independent of implementation
| (cf. CPython, Cython nee pyrex, Stackless Python, Jython, IronPython,
| and PyPy).
`----

Pshaw... Doesn't GVR eschew ++Lambda++ in p3k? Heresy!

,----
| Speaking of Common Lisp, since it has a package scheme, you might be
| able to implement the elisp interpreter by using the elisp
| interpreter, and put in in a package that uses elisp eval instead of
| Common Lisp's eval.
`----

Sam Steingold has explored this in the CLOCC.

There is also LICE.

Pretty sure Closure has an "Emacs like" editor for Mac environs.

PJB maintains quite a bit of Elisp<-->Common-Lisp code.

FWIW I've been collecting various bits and pieces from the above mentioned
sources into a personal package for the last ~6 months.

I'm sure many Common Lispers do similarly.

Also, as mentioned there is Climacs which is quite functional with McClim/CLX.

Likewise, there is Hemlock. (AIUI someone is currently porting it to Qt...)

Also, there are any number of legacy "Emacs like" editors from the
Lispm/TI/Symbolics/BBN/Xerox... implementations. Source is generally available
for all of these.

Contemporary commercial sources like Lispworks and Allegro provide "Emacs like"
editors.

Given Emacs' Maclisp lineage and the number of Lisp2 users whom actively use
GNU/Xemacs (or some equivalent) and the presence of a formal Common Lisp
specification implemented on myriad platforms and multiple
implementations of said
specification, why on earth should a switch to either a Scheme/Python VM warrant
consideration.

FWIW I find it quite odd that discussions of moving the Emacs VM to
Guile are bandied
about when Clisp is available as a GNU project (since forever), has an existing
C interface, is easily as portable across platformas as Guile scheme, counts
among its core authors a formidable contributor to various high-level
GNU projects
(Bruno Haible) and has the admirable quality that it doesn't get confused
between nil/empty-list/falsehood in the way that a Scheme will.

--
/s_P\



^ permalink raw reply	[flat|nested] 71+ messages in thread
* Re: return
@ 2010-11-26 23:01 MON KEY
  0 siblings, 0 replies; 71+ messages in thread
From: MON KEY @ 2010-11-26 23:01 UTC (permalink / raw)
  To: emacs-devel; +Cc: larsi, Tassilo Horn, Stefan Monnier

> just out of inertia but also because I like a more functional style
> of programming: usually/often you can find a formulation that's just
> as elegant without the need for an early exit.

I don't see how (of itself) this preference is sufficiently applicable.

W/re the current inertia of the Emacs lisp VM, it seems whatever
"elegance" gained by the "functional" style it provides is per the
dynamic scoping, and even so it still _requires_ dynamic non-local
exits with catch/throw.

How do you anticipate reconciling this preference in terms of lexbind
integration? The impression I'm given from the CL ANSI spec is that
the `block'/`return-from' special forms (despite their "non-elegance")
were desirable/needed in lieu of dynamic shadowing other dynamic
shadowing concerns w/re transfer of control on exit, e.g.

Section 3.1.5 "Shadowing" of the Common Lisp ANSI spec:
(URL `http://www.ai.mit.edu/projects/iiip/doc/CommonLISP/HyperSpec/Body/sec_3-1-5.html')

Note, in particular that the above should not be considered without
consideration of the impact this hs w/re to Common Lisps treatment of
Closures and Lexical Binding e.g. the immediately preceding section 3.1.4.

and the X3J13 Exit Extent Issue:

,----
|
|     The extent of an exit is not the same thing as the scope of the
|     designator by which the exit is identified. For example, a BLOCK
|     name has lexical scope but the extent of its exit is dynamic; the
|     scope of a CATCH tag could differ from the extent of the CATCH's
|     return point. (That's part of what is at issue here.)
|
`----
:SEE (URL `http://www.ai.mit.edu/projects/iiip/doc/CommonLISP/HyperSpec/Issues/iss152-writeup.html')

In reading the second link above it's pretty clear that this issue had
an immediate affect on `unwind-protect'. Indeed, to the extent :P this
is so, discussion/dismissals of block/return-from should take into the
historic tension between Maclisp derived lisps dialects and the Scheme
derived lisp dialects around `unwind-protect'.

IOW, It almost certainly wasn't simply as a matter of personal
preference that the Common Lisp people incorporated and subsequently
debated the correct implementation of the things.

> We could also provide (and encourage the use of) Scheme's named-let,
> although it tends to be "too powerful" (not inherently
> tail-recursive, so making it efficient (CPU-wise and
> stack-space-wise) would require a good bit more work).

So, how then is `named-let' a somehow better/cleaner solution than an
alternative first-class implementation of a `block'/`return-from'
regime?

--
/s_P\



^ permalink raw reply	[flat|nested] 71+ messages in thread
* return
@ 2010-11-26  8:57 Lars Magne Ingebrigtsen
  2010-11-26  9:19 ` return Tassilo Horn
                   ` (2 more replies)
  0 siblings, 3 replies; 71+ messages in thread
From: Lars Magne Ingebrigtsen @ 2010-11-26  8:57 UTC (permalink / raw)
  To: emacs-devel

Wouldn't it be nice if Emacs Lisp had a workable early-return mechanism?

(This is where Andreas chimes in with "What's wrong with <foo>?")

While debugging and fixing stuff, I often find myself in the situation
of adding more if/cond statements to a function and pushing the original
body further in.  I think this usually leads to less clear code.

Like with 

(defun foo ()
  ... lots of code)

the options are usually

(defun foo ()
  (if zot
      t
    ... lots of code))

or (the horror!)

(defun foo ()
  (block nil
    (when zot
       (return t))
    ... lots of code))

or

(defun foo ()
  (if zot
      t
    (foo-1)))

(defun foo-1 ()
  ... lots of code)

and so on.  I think the ideal way to deal with this is to be more C-ish,
and say

(defun foo ()
  (when zot
    (return t))
  ... lots of code)

That is, I think it would probably be pretty nice if every defun
establishes a nil block.  So this wouldn't be a Common Lisp-ism, but
better!  :-)

(If we want to avoid confusion with the CL return, then we could call it
something else, like freturn.)

This isn't the only use case, of course.  A lot of functions in Emacs go
through pretty awkward contortions to end loops when certain conditions
occur.  A simple return from the middle of a complex series of loops can
often make the code a lot more readable.  (And probably faster.)

Thoughts?
  
-- 
(domestic pets only, the antidote for overdose, milk.)
  larsi@gnus.org * Lars Magne Ingebrigtsen




^ permalink raw reply	[flat|nested] 71+ messages in thread

end of thread, other threads:[~2010-12-23  5:39 UTC | newest]

Thread overview: 71+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-12-05 23:55 Return MON KEY
2010-12-06  1:48 ` Return Stephen J. Turnbull
2010-12-06  5:50   ` Return MON KEY
2010-12-06  7:20     ` Return Stephen J. Turnbull
2010-12-06  9:00       ` Return David Kastrup
2010-12-06 19:11         ` Return Stefan Monnier
2010-12-06 19:09       ` Return Stefan Monnier
2010-12-06 19:19         ` Return Chong Yidong
2010-12-06 20:27           ` Return Stefan Monnier
2010-12-07  4:47         ` Return Miles Bader
2010-12-07  9:17           ` Return David Kastrup
2010-12-07 17:10             ` Return Stefan Monnier
2010-12-07 22:15               ` Return David Kastrup
2010-12-08 15:50             ` Return Fren Zeee
2010-12-09 22:38             ` Return Stefan Monnier
2010-12-10  1:41               ` Return Stephen J. Turnbull
2010-12-10  3:44                 ` Return Stefan Monnier
2010-12-10  8:28                   ` Return Stephen J. Turnbull
2010-12-23  5:39                     ` Return Fren Zeee
2010-12-07 12:44         ` Return Stephen J. Turnbull
2010-12-07 14:38           ` Return David Kastrup
2010-12-07 16:14             ` Return Stephen J. Turnbull
2010-12-07 17:11               ` Return tomas
2010-12-07  2:42       ` Return MON KEY
2010-12-07 14:34         ` Return Stephen J. Turnbull
2010-12-07 15:54           ` Return David Kastrup
2010-12-07 16:30             ` Return Stephen J. Turnbull
2010-12-08 13:42               ` Return Richard Stallman
2010-12-10  7:42               ` Return Daniel Colascione
2010-12-10  8:53                 ` Keyword args (was: Return) Helmut Eller
2010-12-13  2:10                   ` Keyword args Daniel Colascione
2010-12-13  8:30                     ` Helmut Eller
2010-12-13 20:00                     ` Andy Wingo
2010-12-14  5:03                       ` Miles Bader
2010-12-14  7:43                         ` Helmut Eller
2010-12-07 22:55           ` Return MON KEY
2010-12-08  7:28             ` Return Stephen J. Turnbull
2010-12-08 18:11               ` Return MON KEY
2010-12-09  8:37                 ` Return Stephen J. Turnbull
2010-12-07 23:21         ` Return Samuel Bronson
2010-12-08  8:06           ` Return Stephen J. Turnbull
2010-12-08 20:51             ` Return Samuel Bronson
  -- strict thread matches above, loose matches on Subject: below --
2010-11-26 23:01 return MON KEY
2010-11-26  8:57 return Lars Magne Ingebrigtsen
2010-11-26  9:19 ` return Tassilo Horn
2010-12-04  2:36   ` return Fren Zeee
2010-12-04  6:18     ` return Stephen J. Turnbull
2010-12-04  6:49       ` return Leo
2010-11-26  9:24 ` return Miles Bader
2010-11-26  9:36   ` return Lars Magne Ingebrigtsen
2010-11-26  9:54     ` return Miles Bader
2010-11-26 10:13       ` return Lars Magne Ingebrigtsen
2010-11-26  9:44   ` return Tassilo Horn
2010-11-26 14:59 ` return Stefan Monnier
2010-11-26 15:45   ` return Lars Magne Ingebrigtsen
2010-11-26 18:40     ` return Stefan Monnier
2010-11-27  1:31       ` return Lars Magne Ingebrigtsen
2010-11-27  2:49         ` return Stefan Monnier
2010-11-27  3:06           ` return Lars Magne Ingebrigtsen
2010-12-03 18:41             ` return Chong Yidong
2010-12-03 18:43               ` return Miles Bader
2010-12-03 19:46                 ` return Chong Yidong
2010-12-03 21:26                   ` return Chong Yidong
2010-12-03 22:29                     ` return Stefan Monnier
2010-12-03 23:00                       ` return Chong Yidong
2010-12-04  1:35                         ` return Stefan Monnier
2010-12-04  3:23                           ` return Chong Yidong
2010-12-06 16:13                         ` return Davis Herring
2010-12-06 17:15                           ` return Chong Yidong
2010-12-03 22:44                     ` return Chong Yidong
2010-12-04  9:22                       ` return Helmut Eller

Code repositories for project(s) associated with this public inbox

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

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).