weird(?) thought about programming languages

Discussion in 'Ruby' started by Albert Chou, Oct 22, 2003.

  1. Albert Chou

    Albert Chou Guest

    This is a multi-part message in MIME format.

    ------_=_NextPart_001_01C3982A.667BB4DC
    Content-Type: text/plain;
    charset="iso-8859-1"
    Content-Transfer-Encoding: quoted-printable

    This thought isn't necessarily about Ruby specifically, though the
    occasional wish expressed here that Ruby have Lisp-like macros added to
    it resonates with it.

    I've been reading Paul Graham's _On Lisp_ to finally learn what all this
    talk of Lisp macros is about, and I've read enough (I'm into chapter 15
    so far) to understand a lot of it, generally speaking. I spent some
    time trying to understand how it might be possible to use macros to give
    Lisp (or Scheme) a syntax that's easier for me to read (for instance, I
    find most of the function names I've encountered in Common Lisp to be
    pretty incomprehensible). I even came across a USENET posting from
    about 1991 from a guy who had done that with Scheme, but I couldn't find
    any more references or a way to contact him. Further searches of the
    Web turned up another discussion about making Scheme need fewer
    parentheses that finally taught me what I think is a core lesson about
    language syntax: it's difficult, if not impossible, to change the
    punctuation of a programming language using its own mechanisms. By
    punctuation I mean how tokens are delimited/defined.

    The discussion about making a less-parenthesized version of Scheme
    concluded that you'd have to write a special-purpose reader (basically
    parser, IIRC) to accomplish the task. Thus you can write as highly
    abstracted and domain-specific a language as you like on top of
    Lisp/Scheme, as long as you adhere to the way these parent languages
    uses parentheses, whitespace, and alphanumeric characters to define
    language tokens. Adding words (and even language constructs, in a
    language that has macros) to a language's vocabulary is easy, but
    redefining how to define words is impossible without stepping outside
    the language. Of course, you could write a parser for your extended
    language in the language you're extending, but my point is there's no
    way to make a parser for the original language work with the extended
    language if you violate the parent language's punctuation rules.

    Whew, just wanted to say that somewhere that someone would understand
    it. Comments welcome, but not necessary.


    Al
    --=20
    Albert Davidson Chou, QA Manager
    TeaLeaf Technology, Inc.
    (415) 932-5031
    | http://www.TeaLeaf.com/

    ------_=_NextPart_001_01C3982A.667BB4DC
    Content-Type: text/html;
    charset="iso-8859-1"
    Content-Transfer-Encoding: quoted-printable

    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN">
    <HTML>
    <HEAD>
    <META HTTP-EQUIV=3D"Content-Type" CONTENT=3D"text/html; =
    charset=3Diso-8859-1">
    <META NAME=3D"Generator" CONTENT=3D"MS Exchange Server version =
    6.0.4418.33">
    <TITLE>weird(?) thought about programming languages</TITLE>
    </HEAD>
    <BODY>
    <!-- Converted from text/plain format -->

    <P><FONT SIZE=3D2>This thought isn't necessarily about Ruby =
    specifically, though the occasional wish expressed here that Ruby have =
    Lisp-like macros added to it resonates with it.</FONT></P>

    <P><FONT SIZE=3D2>I've been reading Paul Graham's _On Lisp_ to finally =
    learn what all this talk of Lisp macros is about, and I've read enough =
    (I'm into chapter 15 so far) to understand a lot of it, generally =
    speaking.&nbsp; I spent some time trying to understand how it might be =
    possible to use macros to give Lisp (or Scheme) a syntax that's easier =
    for me to read (for instance, I find most of the function names I've =
    encountered in Common Lisp to be pretty incomprehensible).&nbsp; I even =
    came across a USENET posting from about 1991 from a guy who had done =
    that with Scheme, but I couldn't find any more references or a way to =
    contact him.&nbsp; Further searches of the Web turned up another =
    discussion about making Scheme need fewer parentheses that finally =
    taught me what I think is a core lesson about language syntax:&nbsp; =
    it's difficult, if not impossible, to change the punctuation of a =
    programming language using its own mechanisms.&nbsp; By punctuation I =
    mean how tokens are delimited/defined.</FONT></P>

    <P><FONT SIZE=3D2>The discussion about making a less-parenthesized =
    version of Scheme concluded that you'd have to write a special-purpose =
    reader (basically parser, IIRC) to accomplish the task.&nbsp; Thus you =
    can write as highly abstracted and domain-specific a language as you =
    like on top of Lisp/Scheme, as long as you adhere to the way these =
    parent languages uses parentheses, whitespace, and alphanumeric =
    characters to define language tokens.&nbsp; Adding words (and even =
    language constructs, in a language that has macros) to a language's =
    vocabulary is easy, but redefining how to define words is impossible =
    without stepping outside the language.&nbsp; Of course, you could write =
    a parser for your extended language in the language you're extending, =
    but my point is there's no way to make a parser for the original =
    language work with the extended language if you violate the parent =
    language's punctuation rules.</FONT></P>

    <P><FONT SIZE=3D2>Whew, just wanted to say that somewhere that someone =
    would understand it.&nbsp; Comments welcome, but not necessary.</FONT>
    </P>
    <BR>

    <P><FONT SIZE=3D2>Al</FONT>

    <BR><FONT SIZE=3D2>-- </FONT>

    <BR><FONT SIZE=3D2>Albert Davidson Chou, QA Manager</FONT>

    <BR><FONT SIZE=3D2>TeaLeaf Technology, Inc.</FONT>

    <BR><FONT SIZE=3D2>(415) 932-5031</FONT>

    <BR><FONT SIZE=3D2> | <A =
    HREF=3D"http://www.TeaLeaf.com/">http://www.TeaLeaf.com/</A></FONT>
    </P>

    </BODY>
    </HTML>
    ------_=_NextPart_001_01C3982A.667BB4DC--
     
    Albert Chou, Oct 22, 2003
    #1
    1. Advertising

  2. Albert Chou

    James Britt Guest

    Albert Chou wrote:

    > This thought isn't necessarily about Ruby specifically, though the
    > occasional wish expressed here that Ruby have Lisp-like macros added to
    > it resonates with it.
    >
    > I've been reading Paul Graham's _On Lisp_ to finally learn what all this
    > talk of Lisp macros is about, and I've read enough (I'm into chapter 15
    > so far) to understand a lot of it, generally speaking.


    I tried reading that, but after about three or four chapters I decided I
    didn't know enough Lisp to follow along. :)

    But I was motivated by the same reason, to better understand macros.

    >

    I spent some
    > time trying to understand how it might be possible to use macros to give
    > Lisp (or Scheme) a syntax that's easier for me to read (for instance, I
    > find most of the function names I've encountered in Common Lisp to be
    > pretty incomprehensible). I even came across a USENET posting from
    > about 1991 from a guy who had done that with Scheme, but I couldn't find
    > any more references or a way to contact him. Further searches of the
    > Web turned up another discussion about making Scheme need fewer
    > parentheses that finally taught me what I think is a core lesson about
    > language syntax: it's difficult, if not impossible, to change the
    > punctuation of a programming language using its own mechanisms. By
    > punctuation I mean how tokens are delimited/defined.


    There was some similar discussion here about implementing a syntax in
    Ruby that would allow one to manipulate XML using near-literal XPath
    syntax (along the lines of ECMAScript and E4X).

    >
    > The discussion about making a less-parenthesized version of Scheme
    > concluded that you'd have to write a special-purpose reader (basically
    > parser, IIRC) to accomplish the task. Thus you can write as highly
    > abstracted and domain-specific a language as you like on top of
    > Lisp/Scheme, as long as you adhere to the way these parent languages
    > uses parentheses, whitespace, and alphanumeric characters to define
    > language tokens. Adding words (and even language constructs, in a
    > language that has macros) to a language's vocabulary is easy, but
    > redefining how to define words is impossible without stepping outside
    > the language. Of course, you could write a parser for your extended
    > language in the language you're extending, but my point is there's no
    > way to make a parser for the original language work with the extended
    > language if you violate the parent language's punctuation rules.


    I believe Phil Thomson has done some work creating a meta-language in
    Ruby to allow QA/testers to write and run scripts that are, techincally,
    Ruby, but do not require any profound understanding of Ruby's nuts and
    bolts. (And Ruby itself is a meta-language on top of C.)

    That sort of thing, as well as Graham's On Lisp macro stuff, is along
    the lines of "build a language, not an application."[0]

    James

    [0] http://www.pragmaticprogrammer.com/ppllc/papers/1998_03.html
     
    James Britt, Oct 22, 2003
    #2
    1. Advertising

  3. Albert Chou

    Phil Tomson Guest

    In article <>,
    James Britt <> wrote:
    >Albert Chou wrote:
    >
    >I believe Phil Thomson has done some work creating a meta-language in
    >Ruby to allow QA/testers to write and run scripts that are, techincally,
    >Ruby, but do not require any profound understanding of Ruby's nuts and
    >bolts. (And Ruby itself is a meta-language on top of C.)


    It was a hardware description language (RHDL). Basically I just took
    advantage of how easy it is to pass code blocks around in Ruby and used
    that feature to create a domain-specific language without having to write
    a special parser.

    Phil
     
    Phil Tomson, Oct 22, 2003
    #3
  4. Albert Chou

    Chris Pine Guest

    If a language included its own parser as an object in the language, then you
    could do it... in a way, I think.

    As far as I know, no language goes that far, yet.

    Chris
     
    Chris Pine, Oct 22, 2003
    #4
  5. Albert Chou

    Phil Tomson Guest

    In article <048601c398ae$0ffd5d20$6501a8c0@blender>,
    Chris Pine <> wrote:
    >If a language included its own parser as an object in the language, then you
    >could do it... in a way, I think.
    >
    >As far as I know, no language goes that far, yet.
    >


    It would be tremendously cool if Ruby included access to it's own parser
    as an object/module.

    Phil
     
    Phil Tomson, Oct 22, 2003
    #5
  6. Albert Chou

    Aaron Son Guest

    On 2003-10-22, Chris Pine <> wrote:
    > If a language included its own parser as an object in the language, then you
    > could do it... in a way, I think.
    >
    > As far as I know, no language goes that far, yet.


    Smalltalk has late-bound mutable classes, and the class responsible for
    parsing is written in Smalltalk.

    --Aaron
     
    Aaron Son, Oct 22, 2003
    #6
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Phil Carmody
    Replies:
    5
    Views:
    349
    spinoza1111
    Apr 22, 2010
  2. dorayme
    Replies:
    1
    Views:
    654
    richard
    Jan 21, 2011
  3. richard
    Replies:
    0
    Views:
    614
    richard
    Jan 21, 2011
  4. richard
    Replies:
    0
    Views:
    653
    richard
    Jan 21, 2011
  5. Beauregard T. Shagnasty

    Re: A Weird Appearance for a Weird Site

    Beauregard T. Shagnasty, Jan 21, 2011, in forum: HTML
    Replies:
    1
    Views:
    461
    Captain Paralytic
    Jan 21, 2011
Loading...

Share This Page