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

Lisp. Lisp is the only language

Name: Anonymous 2011-01-31 10:29

Why there are other programming languages besides Lisp? With Lisp's macro system you can create any language you need ever. Small, big, finely tuned for your task. Supporting other languages means opposing progress and delaying the inevitable future. There should be only one language and myriad languages at the same time. The one language is Lisp.

Name: Anonymous 2011-02-02 13:21

>>121
I never said anything about touring-completeness. I did however specifically worded my statement as "to write a program that has certain form and does certain things. I say that having closures allows you to do anything you can do with macros, in a more or less similar fashion".
I say that being Turing-complete allows you to do anything you can do with another Turing-complete language, {b in a more or less similiar fashion}.

You can't do that in BASIC.
You can't do that in C.

Why does that matter?
Because the code is data if and only if the code {i is} data.

You keep pointing out some differences that I honestly consider superficial, without even trying to explain why these are important.
I already explained it many times, the code must be data to be called data, the data must be code to be called code.
The generated code must be evaluable in the current scope, because I want a program that writes a program to modify itself, not a program that writes a program that does something, that would be just stupid.

Yes, when I write return eval('lambda x: {}'.format(n)) simple string substitution happens instead of symbol substitution in AST.
But your data is not code and your code is not data. You can't do (write '(my configuration list) my-configuration-file), then (read my-configuration-file) and return the same list.

Why the fuck should I care? It's the "how", the result is the same.
Not the same, read above.

Here, look at the Python goto module: http://entrian.com/goto/download.html
Now implement multiline lambdas, without writing 100M LoC.

MY EYES.
We all know that the DSL's syntax is terrible{spoiler.i !}, but it's a good example of {i macros}.

It could be even nicer to be able to implement one yourself.
(define-syntax (lc stx)
  (syntax-case stx ()
    ((~ expr (a b c) . r)
     #'(map (lambda (a) (~ expr . r))
            (filter (lambda (x) (c x)) b)))
    ((~ expr (a b) . r)
     #'(map (lambda (a) (~ expr . r)) b))
    ((~ expr) #'expr)))

(lc (+ b c)
    (b '(1 2 3 4 5 6) even?)
    (c '(1 3 5)))

(define-syntax (lc2 stx)
  (syntax-case stx (for in when select)
    ((lc for var in xs when p r ...)
     #'(map (lambda (var) (lc r ...)) (filter p xs)))
    ((lc for var in xs r ...)
     #'(map (lambda (var) (lc r ...)) xs))
    ((lc select b) #'b)))

(lc2
 for b in '(1 2 3 4 5 6) when even?
 for c in '(1 3 5)
 select (+ b c))
[code]

but not that much nicer than lst.Where(x => x > 0).Select(x => x * 2).
[code](map (lambda (b c) (+ b c)) (filter even? '(1 2 3 4 5 6)) '(1 3 5)))


There are much more interesting and difficult problems in programming than applying minor changes to syntax.

(defmonadfn >>= (m x f)
  #:apply #'((monad-base-bind m) f x)
  #:id #'(monad-base-bind m))
(defmonadfn >> (m f g)
  #:apply #'(>>= m f (λ (_) g))
  #:id #'(λ (f g) (>> m f g)))
(defmonadfn return (m x)
  #:apply #'((monad-base-return m) x)
  #:id #'(monad-base-return m))
(defmonadfn mplus (m x y)
  #:apply #'((monad-plus-mplus m) x y)
  #:id #'(monad-plus-mplus m))
(defmonadfn mzero (m)
  #:apply #'(mzero (current-monad))
  #:id #'(monad-plus-mzero m))
(defmonadfn m-lift (m n f)
  #:apply
  (let* ((xs (map gensym (make-list (syntax->datum #'n) 'x)))
         (zipxs (map (λ (x y) (list x (list #'return y))) xs xs)))
    #`(lambda #,xs
        (do-monad m #,zipxs
          (f #,@xs))))
  #:id #f)


minor changes to syntax
Read above.

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