Design Patterns
1
Name:
Anonymous
2011-04-21 16:07
Fuck em!
2
Name:
Anonymous
2011-04-21 16:50
Eh?
Give me a link to pic: "Have you read your SICP today?" -with-the-crazy-trouser-snake-guy !
3
Name:
Anonymous
2011-04-22 9:40
Design patterns are useful when communicating design decisions to fellow programmers. Therein, they form a baseline vocabulary.
Saying ``fuck em!'' merely shows your ignorance to the team-oriented nature of software development.
4
Name:
Anonymous
2011-04-22 10:26
Only inferior languages, without macros, have Design Patterns. In LISP we don't even notice them.
5
Name:
Anonymous
2011-04-22 10:36
``Pattern'' you say? Oh, those things I abstract away with higher-order procedures and macros and never see again!
6
Name:
Anonymous
2011-04-22 10:57
7
Name:
Anonymous
2011-04-22 11:24
TDD TDD TDD TDD TDD TDD
8
Name:
Anonymous
2011-04-22 11:29
9
Name:
Anonymous
2011-04-22 11:39
>>4,5
You might be interested in the fact that Richard P. Gabriel, who popularized the notion of patterns in software, was (and remains) a prominent Lisp hacker, one of the few real authorities on everything Common Lisp. And his papers on the subject use CL in the examples. He saw the need for design patterns as an alternative to opaque abstraction, which, as he realized, sucks really hard when you want to do something complex enough.
So when you kids say these stupid things about macros and shit making patterns "unnecessary", you only show that you've never went beyond fibs and facs in your personal development as programmers. Also, that you don't know shit about LISP history and the people who influenced it.
10
Name:
Anonymous
2011-04-22 11:43
11
Name:
Anonymous
2011-04-22 12:04
>>9
There are 5 people in the world that use Lisp. No one else cares. Really. No one. Recognize the truth already, grasshopper.
12
Name:
Anonymous
2011-04-22 12:19
>>11
The truth is, exaggeration hurts everybody.
13
Name:
Anonymous
2011-04-22 12:44
>>11
My bad there's maybe 500 out of 4.6G people that use Lisp.
14
Name:
Anonymous
2011-04-22 12:46
>>9
Gabriel worked on a C++ compiler at the time, by cause of hype surrounding this crappy language. As C++ have no support for macros, he had to invent some boilerplate alternative.
15
Name:
Anonymous
2011-04-22 12:50
>>9
you don't know shit about LISP history and the people who influenced it.
Steele (a designer of Scheme) also worked on Java. Should we say that JAVA better than Scheme?
16
Name:
Anonymous
2011-04-22 12:52
17
Name:
Anonymous
2011-04-22 13:03
>>16
Into the Ground: C++
Q.E.D.
18
Name:
Anonymous
2011-04-22 13:05
And, BTW, idiomatic LISP has no OOP. Just lists and functions on lists.
19
Name:
Anonymous
2011-04-22 13:11
>>18
And this is why Lisp projects never go anywhere. Because of people like you. I wholeheartedly say this, fuck you.
20
Name:
Anonymous
2011-04-22 13:35
>>19
Probably started by retards with Java/C++-background, who overuse CLOS, hygiene and the shits.
smart LISP:
defmacro
retarded LISP:
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
21
Name:
Anonymous
2011-04-22 13:51
>>20
U MENA
&allow-other-keys &aux &body &environment &key &optional &rest &whole * ** *** *break-on-signals* *compile-file-pathname* *compile-file-truename* *compile-print* *compile-verbose* *debug-io* *debugger-hook* *default-pathname-defaults* *error-output* *features* *gensym-counter* *load-pathname* *load-print* *load-truename* *load-verbose* *macroexpand-hook* *modules* *package* *print-array* *print-base* *print-case* *print-circle* *print-escape* *print-gensym* *print-length* *print-level* *print-lines* *print-miser-width* *print-pprint-dispatch* *print-pretty* *print-radix* *print-readably* *print-right-margin* *query-io* *random-state* *read-base* *read-default-float-format* *read-eval* *read-suppress* *readtable* *standard-input* *standard-output* *terminal-io* *trace-output* + ++ +++ - / // /// /= 1+ 1- < <= = > >= abort abs acons acos acosh add-method adjoin adjust-array adjustable-array-p allocate-instance alpha-char-p alphanumericp and append apply apropos apropos-list aref arithmetic-error arithmetic-error-operands arithmetic-error-operation array array-dimension array-dimension-limit array-dimensions array-displacement array-element-type array-has-fill-pointer-p array-in-bounds-p array-rank array-rank-limit array-row-major-index array-total-size array-total-size-limit arrayp ash asin asinh assert assoc assoc-if assoc-if-not atan atanh atom base-char base-string bignum bit bit-and bit-andc1 bit-andc2 bit-eqv bit-ior bit-nand bit-nor bit-not bit-orc1 bit-orc2 bit-vector bit-vector-p bit-xor block boole boole-1 boole-2 boole-and boole-andc1 boole-andc2 boole-c1 boole-c2 boole-clr boole-eqv boole-ior boole-nand boole-nor boole-orc1 boole-orc2 boole-set boole-xor boolean both-case-p boundp break broadcast-stream broadcast-stream-streams built-in-class butlast byte byte-position byte-size caaaar caaadr caaar caadar caaddr caadr caar cadaar cadadr cadar caddar cadddr caddr cadr call-arguments-limit call-method call-next-method car case catch ccase cdaaar cdaadr cdaar cdadar cdaddr cdadr cdar cddaar cddadr cddar cdddar cddddr cdddr cddr cdr ceiling cell-error cell-error-name cerror change-class char char-code char-code-limit char-downcase char-equal char-greaterp char-int char-lessp char-name char-not-equal char-not-greaterp char-not-lessp char-upcase char/= char< char<= char= char> char>= character characterp check-type cis class class-name class-of clear-input clear-output close clrhash code-char coerce compilation-speed compile compile-file compile-file-pathname compiled-function compiled-function-p compiler-macro compiler-macro-function complement complex complexp compute-applicable-methods compute-restarts concatenate concatenated-stream concatenated-stream-streams cond condition conjugate cons consp constantly constantp continue control-error copy-alist copy-list copy-pprint-dispatch copy-readtable copy-seq copy-structure copy-symbol copy-tree cos cosh count count-if count-if-not ctypecase
22
Name:
Anonymous
2011-04-22 13:51
debug decf declaim declaration declare decode-float decode-universal-time defclass defconstant defgeneric define-compiler-macro define-condition define-method-combination define-modify-macro define-setf-expander define-symbol-macro defmacro defmethod defpackage defparameter defsetf defstruct deftype defun defvar delete delete-duplicates delete-file delete-if delete-if-not delete-package denominator deposit-field describe describe-object destructuring-bind digit-char digit-char-p directory directory-namestring disassemble division-by-zero do do* do-all-symbols do-external-symbols do-symbols documentation dolist dotimes double-float double-float-epsilon double-float-negative-epsilon dpb dribble dynamic-extent ecase echo-stream echo-stream-input-stream echo-stream-output-stream ed eighth elt encode-universal-time end-of-file endp enough-namestring ensure-directories-exist ensure-generic-function eq eql equal equalp error etypecase eval eval-when evenp every exp export expt extended-char fboundp fceiling fdefinition ffloor fifth file-author file-error file-error-pathname file-length file-namestring file-position file-stream file-string-length file-write-date fill fill-pointer find find-all-symbols find-class find-if find-if-not find-method find-package find-restart find-symbol finish-output first fixnum flet float float-digits float-precision float-radix float-sign floating-point-inexact floating-point-invalid-operation floating-point-overflow floating-point-underflow floatp floor fmakunbound force-output format formatter fourth fresh-line fround ftruncate ftype funcall function function-keywords function-lambda-expression functionp gcd generic-function gensym gentemp get get-decoded-time get-dispatch-macro-character get-internal-real-time get-internal-run-time get-macro-character get-output-stream-string get-properties get-setf-expansion get-universal-time getf gethash go graphic-char-p handler-bind handler-case hash-table hash-table-count hash-table-p hash-table-rehash-size hash-table-rehash-threshold hash-table-size hash-table-test host-namestring identity if ignorable ignore ignore-errors imagpart import in-package incf initialize-instance inline input-stream-p inspect integer integer-decode-float integer-length integerp interactive-stream-p intern internal-time-units-per-second intersection invalid-method-error invoke-debugger invoke-restart invoke-restart-interactively isqrt keyword keywordp labels lambda lambda-list-keywords lambda-parameters-limit last lcm ldb ldb-test ldiff least-negative-double-float least-negative-long-float least-negative-normalized-double-float least-negative-normalized-long-float least-negative-normalized-short-float least-negative-normalized-single-float least-negative-short-float least-negative-single-float least-positive-double-float least-positive-long-float least-positive-normalized-double-float least-positive-normalized-long-float least-positive-normalized-short-float least-positive-normalized-single-float least-positive-short-float least-positive-single-float length let let* lisp-implementation-type lisp-implementation-version list list* list-all-packages list-length listen listp load load-logical-pathname-translations load-time-value locally log logand logandc1 logandc2 logbitp logcount logeqv logical-pathname logical-pathname-translations logior lognand lognor lognot logorc1 logorc2 logtest logxor long-float long-float-epsilon long-float-negative-epsilon long-site-name loop loop-finish lower-case-p
23
Name:
Anonymous
2011-04-22 13:51
machine-instance machine-type machine-version macro-function macroexpand macroexpand-1 macrolet make-array make-broadcast-stream make-concatenated-stream make-condition make-dispatch-macro-character make-echo-stream make-hash-table make-instance make-instances-obsolete make-list make-load-form make-load-form-saving-slots make-method make-package make-pathname make-random-state make-sequence make-string make-string-input-stream make-string-output-stream make-symbol make-synonym-stream make-two-way-stream makunbound map map-into mapc mapcan mapcar mapcon maphash mapl maplist mask-field max member member-if member-if-not merge merge-pathnames method method-combination method-combination-error method-qualifiers min minusp mismatch mod most-negative-double-float most-negative-fixnum most-negative-long-float most-negative-short-float most-negative-single-float most-positive-double-float most-positive-fixnum most-positive-long-float most-positive-short-float most-positive-single-float muffle-warning multiple-value-bind multiple-value-call multiple-value-list multiple-value-prog1 multiple-value-setq multiple-values-limit
name-char namestring nbutlast nconc next-method-p nil nintersection ninth no-applicable-method no-next-method not notany notevery notinline nreconc nreverse nset-difference nset-exclusive-or nstring-capitalize nstring-downcase nstring-upcase nsublis nsubst nsubst-if nsubst-if-not nsubstitute nsubstitute-if nsubstitute-if-not nth nth-value nthcdr null number numberp numerator nunion oddp open open-stream-p optimize or otherwise output-stream-p package package-error package-error-package package-name package-nicknames package-shadowing-symbols package-use-list package-used-by-list packagep pairlis parse-error parse-integer parse-namestring pathname pathname-device pathname-directory pathname-host pathname-match-p pathname-name pathname-type pathname-version pathnamep peek-char phase pi plusp pop position position-if position-if-not pprint pprint-dispatch pprint-exit-if-list-exhausted pprint-fill pprint-indent pprint-linear pprint-logical-block pprint-newline pprint-pop pprint-tab pprint-tabular prin1 prin1-to-string princ princ-to-string print print-not-readable print-not-readable-object print-object print-unreadable-object probe-file proclaim
24
Name:
Anonymous
2011-04-22 13:52
prog prog* prog1 prog2 progn program-error progv provide psetf psetq push pushnew quote random random-state random-state-p rassoc rassoc-if rassoc-if-not ratio rational rationalize rationalp read read-byte read-char read-char-no-hang read-delimited-list read-from-string read-line read-preserving-whitespace read-sequence reader-error readtable readtable-case readtablep real realp realpart reduce reinitialize-instance rem remf remhash remove remove-duplicates remove-if remove-if-not remove-method remprop rename-file rename-package replace require rest restart restart-bind restart-case restart-name return return-from revappend reverse room rotatef round row-major-aref rplaca rplacd safety satisfies sbit scale-float schar search second sequence serious-condition set set-difference set-dispatch-macro-character set-exclusive-or set-macro-character set-pprint-dispatch set-syntax-from-char setf setq seventh shadow shadowing-import shared-initialize shiftf short-float short-float-epsilon short-float-negative-epsilon short-site-name signal signed-byte signum simple-array simple-base-string simple-bit-vector simple-bit-vector-p simple-condition simple-condition-format-arguments
simple-condition-format-control simple-error simple-string simple-string-p simple-type-error simple-vector simple-vector-p simple-warning sin single-float single-float-epsilon single-float-negative-epsilon sinh sixth sleep slot-boundp slot-exists-p slot-makunbound slot-missing slot-unbound slot-value software-type software-version some sort space special special-operator-p speed sqrt stable-sort standard standard-char standard-char-p standard-class standard-generic-function standard-method standard-object step storage-condition store-value stream stream-element-type stream-error stream-error-stream stream-external-format streamp string string-capitalize string-downcase string-equal string-greaterp string-left-trim string-lessp string-not-equal string-not-greaterp string-not-lessp string-right-trim string-stream string-trim string-upcase string/= string< string<= string= string> string>= stringp structure structure-class structure-object style-warning sublis subseq subsetp subst subst-if subst-if-not substitute substitute-if substitute-if-not subtypep svref sxhash symbol symbol-function symbol-macrolet symbol-name symbol-package symbol-plist symbol-value symbolp synonym-stream synonym-stream-symbol
t tagbody tailp tan tanh tenth terpri the third throw time trace translate-logical-pathname translate-pathname tree-equal truename truncate two-way-stream two-way-stream-input-stream two-way-stream-output-stream type type-error type-error-datum type-error-expected-type type-of typecase typep unbound-slot unbound-slot-instance unbound-variable undefined-function unexport unintern union unless unread-char unsigned-byte untrace unuse-package unwind-protect update-instance-for-different-class update-instance-for-redefined-class upgraded-array-element-type upgraded-complex-part-type upper-case-p use-package use-value user-homedir-pathname values values-list variable vector vector-pop vector-push vector-push-extend vectorp
warn warning when wild-pathname-p with-accessors with-compilation-unit with-condition-restarts with-hash-table-iterator with-input-from-string with-open-file with-open-stream with-output-to-string with-package-iterator with-simple-restart with-slots with-standard-io-syntax write write-byte write-char write-line write-sequence write-string write-to-string y-or-n-p yes-or-no-p zerop
25
Name:
not >>20
2011-04-22 13:58
>>21-24
>>20 only listed the macro-related symbols, not the whole list of symbols part of the language.
To be fair,
defmacro isn't that simple, but it's considerably simpler than Scheme's macro machinery.
defmacro requires a macro lambda list parser to be implemented properly, however that's still simpler than what Scheme has.
26
Name:
Anonymous
2011-04-22 14:15
>>25
require statements are not symbols, I know that
defmacro is much simpler than Scheme's hygienic macros, but it's not the only macro-related symbol in CL.
Besides, I
HBTB >>20 .
27
Name:
Anonymous
2011-04-22 14:16
>>25
but it's considerably simpler than Scheme's macro machinery.
You're saying this as if it were something good.
There's the complexity of the problems you want to solve. If the complexity of your tools is lower than that, it only means that the excessive (and usually much amplified) complexity is pushed to your code -- or that your code does not solve the problem acceptably.
Also, I don't get it: you guys should be ashamed of your inability to understand "complex" things. That means that you're stupid. Instead you're kind of proud of your deficiency.
28
Name:
Anonymous
2011-04-22 14:25
>>26
But you've to write
(require (lib "stxparam.ss" "mzlib")) syntax? (require mzlib/defmacro) boilerplate before writing macros.
29
Name:
Anonymous
2011-04-22 14:26
you guys should be ashamed of your inability to understand "complex" things. That means that you're stupid. Instead you're kind of proud of your deficiency.
Making the simple complicated is commonplace; making the complicated simple, awesomely simple, that's creativity.
Perfection is achieved when there is nothing left to remove. -- Exupery
30
Name:
Anonymous
2011-04-22 14:33
>>27
>There's the complexity of the problems you want to solve. If the complexity of your tools is lower than that, it only means that the excessive (and usually much amplified) complexity is pushed to your code -- or that your code does not solve the problem acceptably.
Malbolge is overly complex. Still it doesn't help me solving problems.
31
Name:
Anonymous
2011-04-22 14:46
>>28
Nope.
(define-syntax (aif stx)
(let ((whole (syntax-e stx)))
(datum->syntax
stx `(let ((it ,(cadr whole)))
(if it ,(caddr whole) ,(cadddr whole))))))
32
Name:
Anonymous
2011-04-22 14:57
>>31
(define-syntax-rule (define-macro (n . x) . b)
(define-syntax (n stx)
(datum->syntax stx (apply (λ x . b) (cdr (syntax->datum stx))))))
(define-syntax-rule (define-hygienic-macro (n rename form) . b)
(define-syntax (n stx)
(datum->syntax stx ((λ (rename form) . b)
(λ (x) (datum->syntax #'here x)) (syntax->datum stx)))))
(define-macro (unhygienic-aif p t f)
`(let ((it ,p))
(if it ,t ,f)))
(define-hygienic-macro (hygienic-aif rename form)
(let ((p (cadr form))
(t (caddr form))
(f (cadddr form)))
`(,(rename 'let) ((it ,p))
(,(rename 'if) it ,t ,f))))
#;
(let ((let 3))
(unhygienic-aif 3 it 4))
(let ((let 3))
(hygienic-aif 3 it 4))
33
Name:
Anonymous
2011-04-22 15:03
>>27
It depends on the problem. I've found
defmacro to be quite a fine facility for my needs, but I do know cases where Scheme's macro system makes for easier macros, but I also know cases where it can lead to unneeded complications.
34
Name:
Anonymous
2011-04-22 15:38
>>33
Implement a counter macro using
defmacro. Each instance of a special name
__counter__ should be substituted with a next natural number, in order of textual appearance.
35
Name:
Anonymous
2011-04-22 15:55
>>34
That's so easy and stupid
!
(define-for-syntax count 0)
(define-syntax (counter stx)
(syntax-case stx ()
((~ x)
(exact-nonnegative-integer? (syntax->datum #'x))
#`#,(begin0 count (set! count (syntax->datum #'x))))
(~ (identifier? #'~) #`#,(begin0 count (set! count (add1 count))))))
counter counter counter counter counter counter ; 0 1 2 3 4 5
(counter 3) counter counter ; 6 3 4
The next is ``now make a macro that defines a counter macro'', right
!
(define-syntax-rule (define-counter id)
(begin
(define-for-syntax count 0)
(define-syntax (id stx)
(syntax-case stx ()
((~ x)
(exact-nonnegative-integer? (syntax->datum #'x))
#`#,(begin0 count (set! count (syntax->datum #'x))))
(~ (identifier? #'~) #`#,(begin0 count (set! count (add1 count))))))))
(define-counter a)
(define-counter b)
a a a a ; 0 1 2 3
b b b ; 0 1 2
a b a b ; 4 3 5 4
36
Name:
Anonymous
2011-04-22 18:26
>>34
That's not what
defmacro (or
macrolet ) is for.
defmacro is a compiler hook for whatever is in the
car of compiled forms.
This doesn't mean that what you want to do isn't trivial in CL, you just use a
symbol macro to do that (
define-symbol-macro or
symbol-macrolet ).
37
Name:
>>36
2011-04-22 18:28
Although if you want to assure that it happens in order of textual appearance, a reader macro which records to current file being compiled would be safer, because someone could use this macro from another file which would continue incrementing the counter.
38
Name:
Anonymous
2011-04-22 23:16
>>34
order of textual appearance.
You're confused. Lisp macros work on SEXPs not on text.
39
Name:
Anonymous
2011-04-22 23:19
>>36
defmacro is a compiler hook for whatever is in the car of compiled forms.
You can devise a Lisp system, that would dispatch on a whole SEXP by pattern-macthing, so infix operators would be possible. Still it would be just a dispatching hook.
40
Name:
Anonymous
2011-04-22 23:22
41
Name:
Anonymous
2011-04-22 23:24
>>39
Infix ops also require changes in lexer, so a+b would be treated as "a + b"
42
Name:
Anonymous
2011-04-22 23:58
>>41
If you're going that far, you may as well write your own reader.
43
Name:
Anonymous
2011-04-23 0:34
>>42
CL's reader supports reader macros.
44
Name:
Anonymous
2011-04-23 0:36
>>43
If all you're going to do is call your own reader in the reader macro, why not just use own reader?
45
Name:
Anonymous
2011-04-23 0:52
>>44
But I want to just discern `+` as a separate symbol!
46
Name:
!89o8tyI8Nk
2011-04-23 1:17
|NIGGER HUT|
47
Name:
Anonymous
2011-04-23 6:04
>>40
(define-syntax-rule (define-counter identifier-that-will-be-bound-to-the-counter)
(begin
(define-for-syntax count-variable-that-will-be-incremented-at-each-\`\`call\'\'-of-the-counter 0)
(define-syntax (identifier-that-will-be-bound-to-the-counter original-syntax-object)
(syntax-case original-syntax-object ()
((identifier-that-will-be-bound-to-the-counter new-value-for-the-counter)
(integer? (syntax->datum (syntax new-value-for-the-counter)))
(datum->syntax original-syntax-object (begin0 count-variable-that-will-be-incremented-at-each-\`\`call\'\'-of-the-counter (set! count-variable-that-will-be-incremented-at-each-\`\`call\'\'-of-the-counter (syntax->datum (syntax new-value-for-the-counter))))))
(rest-case-that-will-be-valid-only-if-it-is-called-as-an-identifier
(identifier? (syntax rest-case-that-will-be-valid-only-if-it-is-called-as-an-identifier))
(datum->syntax original-syntax-object (begin0 count-variable-that-will-be-incremented-at-each-\`\`call\'\'-of-the-counter (set! count-variable-that-will-be-incremented-at-each-\`\`call\'\'-of-the-counter (+ count-variable-that-will-be-incremented-at-each-\`\`call\'\'-of-the-counter 1)))))))))
Happy now?