Beefy Boxes and Bandwidth Generously Provided by pair Networks
"be consistent"

Re^4: Overcoming addiction to Lisp

by Anonymous Monk
on Jun 16, 2005 at 21:26 UTC ( #467447=note: print w/replies, xml ) Need Help??

in reply to Re^3: Overcoming addiction to Lisp
in thread Overcoming addiction to Lisp

What is the special feature about those examples that couldn't have been done just as well (or succinctly, or whatever) without macros?

Replies are listed 'Best First'.
Re^5: Overcoming addiction to Lisp
by Anonymous Monk on Jun 16, 2005 at 22:01 UTC
    All three (in different ways) aim to provide a syntax for concisely expressing something that otherwise could only be expressed via some (rather convoluted) coding patterns. That is, they provide syntactic abstractions (which is what macros are really all about.) But you'll get a far better explanation from the chapters I pointed to than I'll be able to type her in this browser window. -Peter
      I typed in MP3, ID3 over at CPAN, and it came up with a module who's core seems to be about 150 lines. And the real meat seems to be...
      (undef, @{$self->{tag}}{qw/title artist album year comment genre_num +/}) = unpack('a3a30a30a30a4a30C1', $buffer);
        Uh, that's parsing ID3v1 which is an intentionally brain-dead-simple formt. I'm pretty certain parsing ID3v2 is not going to boil down to a single unpack call. (Among other things, in ID3v2, you need to read and decode various lengths and tags in order to know how to interpret the bytes you read next.) Also, note that the Parsing Binary Data chapter provides a way to write parsers for pretty much any binary format *and* allows you to express them in a way that is often just a transliteration of the format's spec. For instance, I originally wrote the library while writing a parser for Java .class files. For the book I wrote the ID3v2 parser in about as much time as it took me to understand the ID3v2 spec. -Peter

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://467447]
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others avoiding work at the Monastery: (5)
As of 2019-10-19 08:01 GMT
Find Nodes?
    Voting Booth?