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

Pages: 1-

The main problem with Racket

Name: Anonymous 2011-04-21 23:19

The main problem with Racket's macro system (and with other syntax-case systems) is that instead of raw s-expressions you're dealing with syntax objects. This becomes very ugly when identifiers are handled: instead of dealing with plain symbols, you're dealing with these syntax values (called “identifiers” in this case) that are essentially a symbol and some opaque information that represents the lexical scope for its source. In several syntax-case systems this is the only difference from defmacro macros, but in the Racket case this applies to everything — identifiers, numbers, other immediate constants, and even function applications, etc — they are all wrapped with additional information.

Name: Anonymous 2011-04-21 23:21

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-04-22 1:04

I try to pop in to this forum from time to time and see if there are any newbie questions I can answer or maybe pick-up a few new tricks. Today marks the longest period of time I have seen between perl posts here --- complete month! I would say that perl is dying. It is still useful to know, but it won't be many people's first choice.

Name: Anonymous 2011-04-22 1:10

Name: Anonymous 2011-04-22 1:40

I have learned the fundamental difference between perl & php - php is much easier to interlace with html, ie jumping in and out to make life easier. I am finding that perl is no where near as flexible, actually I don't think it's possible, and even if it is, it wouldn't be considered good practise.

Name: Anonymous 2011-04-22 1:42

Good gawd, WRRRRYYYYYYYYYY? :S
srsly?
Whysubject yourself to this? Use a damn GUI editor -- WE HAVE THEM U KNOW? :) :D

Name: Anonymous 2011-04-22 1:43

gedit does a fine job at highlighting most recognized formats! As mattr of fact!!!!

Name: Anonymous 2011-04-22 1:49

racket code isn't data, so you can't really expect much from the language. tsk.

Name: Anonymous 2011-04-22 1:50

is racket even turing-complete?

Name: Anonymous 2011-04-22 1:57

>>8
Does anybody do anything useful with code=data? I've never found any compelling reason to do so.

Name: Anonymous 2011-04-22 1:58

>>10
self modifying code
polymorphic virii

Name: Anonymous 2011-04-22 2:01

I hav made a code that made a code that made a code that then simplified somes code that then called Glen Beck who didnt help and then simplified more code in spite of that.

Name: Anonymous 2011-04-22 2:02

instead of raw s-expressions you're dealing with syntax objects.
Such things are good for academy and PhD's.

http://en.wikipedia.org/wiki/Rube_Goldberg_machine

Name: Anonymous 2011-04-22 3:22

The main problem with Common Lisp's macro system (and with other define-macro systems) is that instead of syntax objects you're dealing with raw s-expressions. This becomes very ugly when using the macro in a different context than it was defined in: instead of dealing with identifiers, you're dealing with these plain data (called “symbols” in this case) that are essentially an identifier stripped of anything but their name, including the lexical scope for its source. In several define-macro systems this is the only difference from hygienic macros, but in the Common Lisp case this combines with its terrible module system (called “packages”) and lack of phasing (eval-when considered harmful to your mental health) to create a system which is only held together by duct tape and prayer.

Name: Anonymous 2011-04-22 3:44

Name: Anonymous 2011-04-22 3:44

>>15
Listen
self fix

Name: Anonymous 2011-04-22 3:46

>>14
Oh. Maybe I *Wont* try LISP, then.
:P
.....I'll just stick to C and things.
I'll read that link 15.

Name: Anonymous 2011-04-22 3:49

Fuck your article 15 it is for fags.

Name: Anonymous 2011-04-22 3:50

>>17
Disregard that Zawinski coded Lisp and had to use C, because of no better alternatives for PC.

Name: Anonymous 2011-04-22 4:50

C macros = text substitution.
CL macros = sexp substitution. (glorified C macros)
Hygienic macros = sexp/syntax substitution, hygiene only on symbols.
Racket macros = sexp/syntax substitution, everything is a syntax object. You can attach properties and information on every piece of syntax. You can write a fucking type system without completely redefine `define', `let', etc.

Name: Anonymous 2011-04-22 5:12

>>20
>fucking type system
Why would I want to?

Name: Anonymous 2011-04-22 5:14

These `syntax-objects` conflict with LISP philoshophy of everything-is-a-list.

Name: Anonymous 2011-04-22 5:55

>>22
They are lists, you moron. So the code is represented as a list of lists of lists, which is twice as conforming to the traditional LISP values.

Name: Anonymous 2011-04-22 6:16

>>23
Then what about the zoo of:
(syntax-e stx) (syntax->datum stx) (syntax->list stx) (syntax-property #'[foo] 'paren-shape) (quote-syntax when) (datum->syntax context-stx input-sexpr) (syntax-rules () ...) (raise-syntax-error ...) (syntax-parameterize ...)  (require (lib "stxparam.ss" "mzlib")) (make-rename-transformer ...) (define-syntax-parameter ..) (syntax-source stx) (syntax-case stx) (define-syntax (while stx) ...) (with-syntax ...) (syntax-position stx) (syntax-line stx) (syntax-column stx)

Name: Anonymous 2011-04-22 6:16

>>24
That is: all these functions instead of simple defmacro.

Name: Anonymous 2011-04-22 11:38

>>24
(require (lib "stxparam.ss" "mzlib"))
CL doesn't have modules!

Syntax objects are sexps.

Name: Anonymous 2011-04-22 19:26

>>14
If you think symbols are simple, you obviously don't know CL well-enough. Symbols are a structure having a name, a value, a functional value, a package (which is a collection of collection of symbols), a plist (which is essentially a tag<->value list) at minimum (implementations may have more).

Name: Anonymous 2011-12-11 20:54

CL's defmacro is available in Racket using (require mzlib/defmacro). I'd strongly advise actually learning Racket's macro system, however, because it allows you to write composable macros that cannot inadvertently capture variables while being able to introduce identifiers as needed.

CL's unhygienic macros are simple to write and understand, but they are not simple to use or compose. Racket's macros are exactly as hard to write as the actual task you're attempting to accomplish: a simple hygienic macro is trivial to write with define-syntax-rules, while a simple unhygienic macro is trivial to write with mzlib/defmacro. It's only when you're trying to do more complex stuff like selectively break hygiene that things get complicated.

DrRacket's macro stepper, incidentally, is very useful for seeing what a macro usage will expand into, and the automatic arrows from identifiers to the macro that introduced them are a life saver.

Name: Anonymous 2011-12-12 13:01

>>28
Just use quasiquote with auto-gensyms, because CL's quasiquote is broken in many ways, that have nothing to do with macros.

Name: Anonymous 2011-12-12 14:42

>>1
Yeah, gosh, why would you want information like scope or location in source ever...

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