Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon.

Pages: 1-

Clojure

Name: Anonymous 2011-05-18 11:32

0]=> clj
Clojure 1.2.0
user=> (defn f [x] (first x))
#'user/f
user=> (f '(1))
1
user=> (binding [first rest] (f '(1)))
()
user=> "WHAT THE FUCK. Will it work with procedures in a different namespace?"
"WHAT THE FUCK. Will it work with procedures in a different namespace?"
user=> (remove even? [1 2 3 4 5 6 7 8])
(1 3 5 7)
user=> (defn g [& rest] "BROKEN")
#'user/g
user=> (binding [filter g] (remove even? [1 2 3 4 5 6 7 8]))
"BROKEN"
user=> "Clojure, the best language of them all. All the power of unhygienic macros, and the usability of Emacs Lisp."
"Clojure, the best language of them all. All the power of unhygienic macros, and the usability of Emacs Lisp."
user=>


Let us compare Clojure with some other Lisp implementations:

Racket
0]=> racket
Welcome to Racket v5.1.1.5.
#;> (define (f x) (car x))
#;> (f '(1))
1
#;> (let ((car cdr)) (f '(1)))
1
#;>

Chicken
0]=> csi

CHICKEN
(c)2008-2010 The Chicken Team
(c)2000-2007 Felix L. Winkelmann
Version 4.6.0
linux-unix-gnu-x86 [ manyargs dload ptables ]
compiled 2010-11-09 on archlinux (Linux)

#;1> (define (f x) (car x))
#;2> (f '(1))
1
#;3> (let ((car cdr)) (f '(1)))
1
#;4>

SBCL
0]=> sbcl
This is SBCL 1.0.48, an implementation of ANSI Common Lisp.
More information about SBCL is available at <http://www.sbcl.org/>;.

SBCL is free software, provided as is, with absolutely no warranty.
It is mostly in the public domain; some portions are provided under
BSD-style licenses.  See the CREDITS and COPYING files in the
distribution for more information.
* (defun f (x) (car x))

F
* (f '(1))

1
* (flet ((car (x) (cdr x))) (f '(1)))
; in: FLET ((CAR (X) (CDR X)))
;     (FLET ((CAR (X)
;              (CDR X)))
;       (F '(1)))
;
; caught WARNING:
;   Compile-time package lock violation:
;     Lock on package COMMON-LISP violated when binding CAR as a local function
;     while in package COMMON-LISP-USER.
;   See also:
;     The SBCL Manual, Node "Package Locks"
;     The ANSI Standard, Section 11.1.2.1.2
;
; caught ERROR:
;   Lock on package COMMON-LISP violated when binding CAR as a local function while
;   in package COMMON-LISP-USER.
;   See also:
;     The SBCL Manual, Node "Package Locks"
;     The ANSI Standard, Section 11.1.2.1.2
;
; compilation unit finished
;   caught 1 ERROR condition
;   caught 1 WARNING condition

debugger invoked on a SB-INT:COMPILED-PROGRAM-ERROR in thread #<THREAD
                                                                "initial thread" RUNNING
                                                                {AAA0679}>:
  Execution of a form compiled with errors.
Form:
  (FLET ((CAR (X)
         (CDR X)))
  (F '(1)))
Compile-time error:
  Lock on package COMMON-LISP violated when binding CAR as a local function while
in package COMMON-LISP-USER.
See also:
  The SBCL Manual, Node "Package Locks"
  The ANSI Standard, Section 11.1.2.1.2

Type HELP for debugger help, or (SB-EXT:QUIT) to exit from SBCL.

restarts (invokable by number or by possibly-abbreviated name):
  0: [ABORT] Exit debugger, returning to top level.

((EVAL (FLET ((CAR (X) (CDR X))))))
0]

Emacs Lisp
*** Welcome to IELM ***  Type (describe-mode) for help.
ELISP> (require 'cl) ; flet
cl
ELISP> (defun f (x) (car x))
f
ELISP> (f '(1))
1
ELISP> (flet ((car (x) (cdr x))) (f '(1)))
nil
ELISP>


Thus, Clojure is utterly broken. Rich Hickey is actually proud of dynamically bound functions.

Name: Anonymous 2011-05-18 11:47

Common Lisp: defmacro
---------------
Scheme/Racket: syntax-e syntax->datum syntax->list syntax-property #' (void) quote-syntax datum->syntax syntax-parameter-value syntax-rule raise-syntax-error internal-definition-context? syntax-parameterize make-set!-transformer syntax-local-value/immediate syntax-local-transforming-module-provides? syntax-local-module-defined-identifiers syntax-local-module-required-identifiers make-require-transformer (require (lib "stxparam.ss" "mzlib")) syntax? (require mzlib/defmacro) syntax-local-lift-expression (require racket/stxparam-exptime) make-rename-transformer syntax-local-require-certifier make-parameter-rename-transformer syntax-local-value define-syntax-parameter make-provide-transformer syntax-local-provide-certifier syntax-source local-expand/capture-lifts local-transformer-expand/capture-lifts syntax-local-lift-values-expression syntax-local-lift-module-end-declaration syntax-local-lift-require syntax-local-lift-provide syntax-local-name syntax-local-context syntax-local-phase-level syntax-local-module-exports syntax-local-get-shadower syntax-local-certifier syntax-transforming? syntax-local-introduce make-syntax-introducer make-syntax-delta-introducer syntax-local-make-delta-introducer syntax-case define-syntax syntax-rules with-syntax syntax-position syntax-line syntax-column ...

Name: Anonymous 2011-05-18 13:40

>>2
Good, you completely missed the point!

Scheme/Racket: syntax syntax-e datum->syntax, the rest is derived syntax.

Name: Anonymous 2011-05-18 14:49

I'm not surprised. Clojure is shit.

Name: Anonymous 2011-05-18 14:56

>>3
Macro in LISP.

(defmacro aif (cond then else)
  `(let ((it ,cond))
     (if it ,then ,else)))


"Macro" in Scheme/Racket.

#lang racket
(require racket/stxparam)
 
(define-syntax-parameter it (lambda (stx) (raise-syntax-error 'anaphora "missed context" stx)))
 
(define-syntax-rule (aif cond then else)
  (let ([temp cond])
    (syntax-parameterize ([it (make-rename-transformer #`temp)])
                         (if temp then else))))

Name: Anonymous 2011-05-18 14:57

>>3
the rest is derived syntax.
Common Lisp: defmacro
Scheme/Racket: over 9000 pages of "derived syntax"

Name: Anonymous 2011-05-18 15:03

fuck i hate these retarded threads. i hope you faggots die in a fire.

Name: Anonymous 2011-05-18 18:17

>>1
You can have dynamically bound functions in CL too, but not by default, you need a library for it.

Name: Anonymous 2011-05-18 19:08

>>8
Please, tell me who would ever do that.

>>5
Macro in LISP.

(defmacro aif (id/cond cond/then then/else &optional maybe-else)
  (let ((id (if (symbolp id/cond) id/cond 'it))
    (cond (if (symbolp id/cond) cond/then id/cond))
    (then (if (symbolp id/cond) then/else cond/then))
    (else (if (symbolp id/cond) maybe-else then/else)))
    `(let ((,id ,cond))
       (if ,id ,then ,else))))


Macro in Racket. (!= Scheme, look at ER macros, faggot)

(define-macro aif
  #:capture it
  ((cond then else)
   (let ((it cond))
     (if it then else)))
  ((id cond then else)
   #:require (identifier? #'id)
   (let ((id cond))
     (if id then else))))


Macro in LISP.

(defmacro acond (&rest cc)
  ; I'm not going to fucking write the whole thing
  ; (acond) => #f
  ; (acond (else b ...)) => (begin b ...)
  ; (acond (e => f)) => (and e (f e))
  ; (acond (e p => f)) => (and e (p e) (f e))
  ; (acond (p -> r b ...)) => (let ((r p)) (and r (begin b ...)))
  ; (acond (p b ...)) => (if p (begin b ...))
  )


Macro in Racket.

(define-macro acond
  #:keyword (else => ->)
  (() #f)
  (((else . b) (begin . b)))
  (((e => f) (r ...) ...)
   (let ((x e))
     (if x (f x) (acond (r ...) ...))))
  (((e p => f) (r ...) ...)
   (let ((x e))
     (if (and x (p x)) (f x) (acond (r ...) ...))))
  (((p -> r . b) (r ...) ...)
   #:require (identifier? #'r)
   (aif r (begin . b) (acond (r ...) ...)))
  (((p . b) (r ...) ...)
   (aif p (begin . b) (acond (r ...) ...))))

Name: >>8 2011-05-18 19:13

>>9
Here's one such implementation http://p-cos.net/documents/dynfun.pdf

Name: Anonymous 2011-05-18 23:43

>>10
Yeah, but why would you ever need them?

Name: Anonymous 2011-05-18 23:52

>>10
Also, it's not rocket science:

(struct dynamic-procedure (f)
  #:mutable #:property prop:procedure
  (λ (f . x)
    (apply ((dynamic-procedure-f f)) x)))

(define-syntax-rule (defdynfun (f . x) . b)
  (define f (dynamic-procedure (make-parameter (lambda x . b)))))
(define-syntax-rule (let-dynfun ((f x . b) ...) . r)
  (parameterize (((dynamic-procedure-f f) (lambda x . b)) ...) . r))

Name: Anonymous 2011-05-19 0:52

>>11
I have not yet have had any need for them, I just pointed out they are possible.

Name: Anonymous 2011-05-19 5:08

lisp macromedia flash

Name: Anonymous 2011-05-19 6:04

>>14
No! It would actually work!!!

Don't change these.
Name: Email:
Entire Thread Thread List