cl o x common lisp objects for xemacs
play

CL O X : Common Lisp Objects for XEmacs Motivation Alternatives - PowerPoint PPT Presentation

CL O X Didier Verna Introduction Context CL O X : Common Lisp Objects for XEmacs Motivation Alternatives Closette ELisp vs. Lisp The CL package Didier Verna Scoping -lists Type/Class didier@xemacs.org Types http://www.xemacs.org


  1. CL O X Didier Verna Introduction Context CL O X : Common Lisp Objects for XEmacs Motivation Alternatives Closette ELisp vs. Lisp The CL package Didier Verna Scoping λ -lists Type/Class didier@xemacs.org Types http://www.xemacs.org Generic Functions http://www.lrde.epita.fr/˜didier Project status Available Features Testing Performance ELS 2010 – Friday, May 7th Conclusion Thanks ! 1/33

  2. Overview CL O X What is it ? Didier Verna ◮ An implementation of C LOS for XEmacs ◮ Including the Meta-Object Protocol (M OP ) Introduction Context What’s in it ? Motivation Alternatives ◮ A port of Closette to Emacs Lisp Closette ◮ Deeper type/class integration ELisp vs. Lisp The CL package ◮ A comprehensive test suite Scoping λ -lists Type/Class Types Generic Functions Project status Available Features Testing Performance Conclusion Thanks ! 2/33

  3. Table of contents CL O X Didier Verna Introduction 1 Introduction Context Closette in Emacs Lisp Motivation 2 Alternatives Closette ELisp vs. Lisp Type/class integration 3 The CL package Scoping λ -lists Type/Class Project status 4 Types Generic Functions Project status Conclusion 5 Available Features Testing Performance Conclusion Thanks ! 4/33

  4. Context The state of XEmacs CL O X About XEmacs Didier Verna ◮ Initially a fork of GNU Emacs v.19-to-be (1991) ◮ Greatly diverged since then Introduction Context ◮ User-level Emacs Lisp compatibility Motivation ◮ Internals compatibility Alternatives Closette About the internals ELisp vs. Lisp The CL package ◮ Very high level of abstraction Scoping ◮ 111 opaque Lisp types, 35 user-level λ -lists Type/Class ◮ Core in “C+”: data-abstraction and OO infrastructure Types Generic Functions Project status Available Features Testing Performance Conclusion Thanks ! 6/33

  5. A couple of “C+” examples So why not use C++ directly ? *plonk* CL O X Polymorphism / Class-like abstraction Didier Verna Introduction struct console Context { Motivation Alternatives enum console_variant contype; void *console_data; Closette struct console_methods *conmeths; ELisp vs. Lisp The CL package / ∗ . . . ∗ / Scoping } λ -lists Type/Class Types Generic Functions Project status Dynamic method lookup Available Features Testing Performance MAYBE_CONMETH (console, mark_console, ...); Conclusion Thanks ! 7/33

  6. Motivation Bring the same level of abstraction to the Lisp layer CL O X Why isn’t it the case already ? Didier Verna ◮ GNU Emacs compatibility ◮ Emacs Lisp backward compatibility Introduction ◮ Less “OO pressure” at the Lisp level Context Motivation • Glue to the C level Alternatives • Not the job of package authors Closette ELisp vs. Lisp • Requires more than the average coding skill The CL package • Ad-hoc abstraction easier to achieve in Lisp Scoping λ -lists What would be the benefits ? Type/Class Types ◮ C-based features: abstract away the Lisp glue Generic Functions ◮ Lisp features: improve maintainability / extensibility Project status ◮ Also for third-party packages ( e.g. Gnus) Available Features Testing Performance Conclusion Thanks ! 8/33

  7. Why C LOS ? Arguments in favor of it CL O X 1 Emacs Lisp Didier Verna ◮ Close to MacLisp and Common Lisp ◮ Many developers familiar with Common Lisp Introduction Context ◮ CL package dependency: 16% files, 27% LoC Motivation Alternatives 2 C LOS Closette ◮ One of the most powerful object system around ELisp vs. Lisp The CL package ◮ Well documented Scoping ◮ No need to start from scratch λ -lists Type/Class 3 Porting Common Lisp libraries to Emacs Lisp Types Generic Functions 4 Attract more Common Lisp developers Project status Available Features 5 Gain expertise in C LOS and its M OP ;-) Testing Performance Conclusion Thanks ! 9/33

  8. Alternatives Other available object systems CL O X 1 E OOPS (Emacs Lisp Object Oriented Programming System) Didier Verna ◮ Message passing (Smalltalk style) ◮ No activity since 1992 Introduction Context ◮ No known Emacs Lisp package using it Motivation Alternatives 2 E IEIO (Enhanced Implementation of Emacs Interpreted Objects) Closette ◮ Active ELisp vs. Lisp The CL package ◮ Part of the C EDET package (70,000 LoC) Scoping ◮ C LOS -like λ -lists Type/Class ◮ Additional features ( e.g. debugging support) Types ◮ Doesn’t aim at being fully compliant Generic Functions Project status Available Features Testing Performance Conclusion Thanks ! 10/33

  9. Emacs Lisp vs. Common Lisp All them dialects, they make my head swim CL O X Fundamental differences Didier Verna ◮ Dynamic vs. lexical scope ◮ No package system, Limited λ -list syntax Introduction Context ◮ Different types, condition system, printing facilities etc. Motivation Alternatives Less obvious ones Closette ◮ Different function names ELisp vs. Lisp The CL package ◮ Similar functions with different semantics Scoping λ -lists ◮ function is different Type/Class (X)Emacs Lisp evolution Types Generic Functions ◮ Self-evaluating keywords since 1996 Project status ◮ #’ syntax since XEmacs 19.8 Available Features Testing ◮ Primitive character type since XEmacs 19.20 Performance ◮ Built-in multiple values since a couple of months Conclusion Thanks ! ◮ XEmacs no later than 21.5 beta 29 \ today is required 12/33

  10. The CL package Common Lisp emulation layer CL O X Provide missing standard utility functions or macros Didier Verna ( e.g. loop ) Introduction Extend existing but limited ones Context Motivation ( e.g. mapcar* ) Alternatives Closette Support full λ -list syntax ELisp vs. Lisp ( defun* , defmacro* etc. ) The CL package Scoping λ -lists typep Type/Class setf / defsetf (no setf functions) Types Generic Functions Project status Available Features Testing Performance Conclusion Thanks ! 13/33

  11. Dynamic vs. lexical scope A CL O X work Orange CL O X CL ’s lexical-let to the rescue Didier Verna Not necessary in most cases Introduction ◮ Local use of let bindings or function parameters Context ◮ “Downward funargs” situations Motivation Alternatives ◮ “Upward funargs” situations in some cases Closette ELisp vs. Lisp ◮ Only 6 actual uses of lexical-let The CL package Scoping λ -lists Type/Class Types Generic Functions Project status Available Features Testing Performance Conclusion Thanks ! 14/33

  12. Downward funargs: example Look at the required-classes argument CL O X Didier Verna (defun compute-applicable-methods-using-classes (gf required-classes) Introduction #| . . . |# Context Motivation (remove-if-not #’(lambda (method) Alternatives (every #’subclassp Closette required-classes ELisp vs. Lisp (method-specializers method))) The CL package Scoping (generic-function-methods gf)) λ -lists #| . . . |# ) Type/Class Types Generic Functions Project status Available Features Testing Performance Conclusion Thanks ! 15/33

  13. Upward funargs: example Look at the next-emfun argument CL O X Didier Verna (defun compute-primary-emfun (methods) (if (null methods) Introduction nil Context Motivation Alternatives ; ; Common Lisp version : Closette (let ((next-emfun (compute-primary-emfun (cdr methods)))) ELisp vs. Lisp #’(lambda (args) The CL package Scoping (funcall (method-function (car methods)) λ -lists args next-emfun))) Type/Class Types ; ; P a r t i a l l y evaluated Emacs Lisp version : Generic Functions (let ((next-emfun (compute-primary-emfun (cdr methods)))) Project status ‘(lambda (args) Available Features (funcall (method-function ’,(car methods)) Testing Performance args ’,next-emfun))) Conclusion Thanks ! 17/33

  14. Upward funargs: explanation Look at the next-emfun argument CL O X Didier Verna ; ; P a r t i a l l y evaluated Emacs Lisp version : (let ((next-emfun (compute-primary-emfun (cdr methods)))) Introduction ‘(lambda (args) Context Motivation (funcall (method-function ’,(car methods)) Alternatives args ’,next-emfun))) Closette ELisp vs. Lisp The CL package Scoping lambda is self-quoting λ -lists Type/Class (lambda ...) is a function designator Types Generic Functions e.g. (funcall ’(lambda (x) x) 1) Project status function ⇐ ⇒ quote + byte-compiler hint Available Features Testing Performance Note: use byte-compile on the resulting form Conclusion Thanks ! 18/33

Download Presentation
Download Policy: The content available on the website is offered to you 'AS IS' for your personal information and use only. It cannot be commercialized, licensed, or distributed on other websites without prior consent from the author. To download a presentation, simply click this link. If you encounter any difficulties during the download process, it's possible that the publisher has removed the file from their server.

Recommend


More recommend