[ ] Emacs Lisp' |
- Emacs Lisp'? Emacs .
:
Emacs', , .
work in progress , Go Emacs Lisp.
, Emacs Lisp "", "design tradeoffs". "" "" , . , , , . .
, Go. Go ?
:
, "" , (3). , Emacs Lisp.
, , , :
- Emacs', Chris Wellons.
Go .
- . :
, , :
go/*
Go.
parser, typechecker frontend' . 20 AST .
. 90% : " AST - Emacs'".
.
API , . go/ast
go/types
; (-, , ).
import' ( ast.GenDecl
).
, , " ". , , ( , ).
, (~80%) . Go , .
:
, , .
, , Emacs Lisp .
, , .
Go , IDE , . , Go gofmt
. go/types
,
go/build
go/*
.
Sublime text, Emacs, Visual Studio Code , (), gorename
, import'. company-elisp
.
Emacs Lisp 1000 . Emacs Go , Emacs Lisp.
, Go Emacs'. ?
Lisp , , , .
int
, float64
, string
- . Go, Emacs Lisp .
, (symbol
) (uintX
).
, " ", Emacs Lisp , lisp.Object
. lisp.Object: .
: Go "" std::vector
C++, subslice .
{data, len, cap}
.
data , len cap . improper list, nil, :
(cons data (cons len cap))
slice-get
/slice-set
. aset
/aget
, car
data.
, subslice?
C data , . , 0-based. , offset:
(cons data (cons offset (cons len cap)))
slice-get
/slice-set
offset.
- slice-get
.
;;
;; [vector]
;; [vector index]
aref ;; [elem]
;; Slice offset ( subslice)
;; [slice]
car ;; [data]
;; [data index]
aref ;; [elem]
;; Slice subslice
;; [slice]
dup ;; [slice slice] (1)
car ;; [slice data]
stack-ref 1 ;; [slice data slice]
cdr ;; [slice data slice.cdr]
car ;; [slice data offset]
;; [slice data offset index]
plus ;; [slice data real-index]
aref ;; [slice elem]
stack-set 1 ;; [elem] (2)
;; (1) ,
;; .
;; (2)
;; slice .
, ( stack-ref
, call
). .
/ Go . lisp.Object
, lisp.Symbol
lisp.Number
.
opaque . .
type Symbol interface {
symbol()
}
type Object interface {
object()
// ...
}
// -.
// Intern returns the canonical symbol with specified name.
func Intern(name string) Symbol
Intern
-. intrinsic .
, API, , , Go.
lisp.Object
" ", interface{}
?
, interface{}
Go , , "".
, , Emacs' " " . lisp.Object
unboxed Emacs Lisp ,
.
, lisp.Object
, .
type Object interface {
object()
Int() int
Float() float64
String() string
// ... etc.
// :
IsInt() bool //
GetInt() (val int, ok bool) // "comma, ok"-style
// ... .
}
. lisp.Object
, panic
. - API reflect.Value
, ?
, , , lisp.Object
.
pair := lisp.Call("cons", 1, "2")
a, b := lisp.Call("car", pair), lisp.Call("cdr", pair)
lisp.Call("insert", "Hello, Emacs!")
sum := lisp.Call("+", 1, 2).Int()
, , .
part := "c"
lisp.Insert("Hello, Emacs!") // void
s := lisp.Concat("a", "b", part) // string, ...string
DSL .
;; , FFI.
(ffi-declare
(concat Concat (:string &parts) :string)
(message Message (:string format :any &args) :string)
(insert Insert (:any &args) :void)
(+ IntAdd (:int &xs) :int))
;; , , Go .
Go . - , Lisp .
// IntAdd - ... < + Emacs>
//$GO-ffi:+
func IntAdd(xs ...int) int
// ...
Emacs' documentation
. docstrings.
Emacs Lisp , Go .
, , :
package "foo" func "f" => "$GO-foo.f"
package "foo/bar" func "f" => "$GO-foo/bar.g"
package "foo" func (typ) "m" => "$GO-foo.typ.m"
package "foo" var "v" => "$GO-foo.v"
, , Go ( , ). $GO
Emacs .
:
, return statement
, goto
( Go).
.
Emacs' lapcode .
lapcode, ,
Emacs .
Lisp assembly program Emacs' (IR). , -.
"" - , .
. , Emacs Lisp' ( ).
Go, "" Emacs VM Emacs Lisp.
?
Emacs Lisp scoping . "emacs/lisp/emacs-lisp/byte-opt.el", ; - , .
Emacs Lisp . , defconstant
, , defvar
. Go , .
Go , Emacs Lisp . , .
Go, / Emacs VM.
.
Emacs Lisp:
string
, vector
, list
/cons
)integer
float
) .
int
float
.
, =
,
.
number
cons
, ,
, ,
, cons
.
boxed ( cons
),
.
car
.
cons
: &x != &x
,
(eq (cons x nil) (cons x nil))
.
.
.
goism , Go Emacs Lisp -.
, lapcode Go.
emacs/rt , goism.
goism ,
,
(guick start guide ).
, ? : , - , .
, - .