[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: XML as a transition to s-expr



Paul Prescod <paul@prescod.net> writes:

> Bruce Lewis wrote:
> > 
> > BRL is substantially more newbie-friendly in the areas PHP is reputed to
> > be friendly in: database integration, e-mail.
> 
> Can you demonstrate?

Most certainly.  Let me just find a simple php mail example to compare
to.  First a google search for "simple php mail example".  Whoa!  Those
are too easy to beat.  Ok, how about php.net?  All the examples here are
too easy to beat as well:
http://www.php.net/manual/en/function.mail.php

I'll have to make one up by combining truly simple PHP examples.  We'll
(1) get some form inputs, (2) embed them in text to be output, and (3)
send them in e-mail.  This is an expansion of the example at
 http://www.php.net/tut.php

      <form action="action.php" method="post">
      Your name: <input type="text" name="name">
      You age: <input type="text" name="age">
      <input type="submit">
      </form>

(1) Get form inputs http://www.php.net/release_4_1_0.php

To get form inputs in a way that works under prior releases as well
as the default configuration for the latest PHP release, 4.1.0:

  name=$HTTP_POST_VARS["name"];
  age=$HTTP_POST_VARS["age"];

Here's the BRL equivalent:

 (inputs name age)

(2) Embed them in text to be output.
    This is cut/paste straight from http://www.php.net/tut.php

Hi <?php echo $name; ?>.
You are <?php echo $age; ?> years old.

Here's the BRL equivalent:

Hi [name].
You are [age] years old.

(3) Send e-mail
    http://www.php.net/manual/en/function.mail.php

<?php
mail("nobody@example.com","$name is $age",
"You just got a form filled in by somebody
claiming to be $name (age $age).");
?>

The BRL equivalent is slightly more verbose, but clearer as to what the
resultant e-mail will look like.

[
 (mail (list "nobody@example.com")
]To: nobody@example.com
Subject: [name] is [age]

You just got a form filled in by somebody
claiming to be [name] (age [age]).
[)]


(4) Put it all together:

================= action.php ===================
<?php
  name=$HTTP_POST_VARS["name"];
  age=$HTTP_POST_VARS["age"];
?>
Hi <?php echo $name; ?>.
You are <?php echo $age; ?> years old.

<?php
mail("nobody@example.com","$name is $age",
"You just got a form filled in by somebody
claiming to be $name (age $age).");
?>


================= action.brl ===================
[(inputs name age)]

Hi [name].
You are [age] years old.

[
 (mail (list "nobody@example.com")
]To: nobody@example.com
Subject: [name] is [age]

You just got a form filled in by somebody
claiming to be [name] (age [age]).
[)]

================= NOTES ===================

Someone will want to claim that this example is too simple; that BRL
will get more confusing than PHP as you add more examples.  The
opposite is true, and newbies posting on the alt.php newsgroup give
continual testimony to this fact.

What if they want a literal double quote in the body of the e-mail?
PHP requires backslashing.  BRL does not.  Typical alt.php question.

What if they want to use foo($age) instead of $age?  In sending output
to the page, they simply change $age to foo($age).  In the body of the
e-mail, they must change $age to ".foo($age).".  Typical alt.php
question.

Note that I made it easy on PHP by choosing an example that didn't
require ${name} and ${age}.  BRL has no analagous issue.

BRL is much more newbie friendly.  What works in one context is much
more likely to work in another context than with PHP.

Do the dollar signs, backslashes, commas and semicolons in PHP really
help make things more readable?  I think not.  Do multiple meanings of
parens and square brackets confuse things with BRL?  Not at all.  [
always means end a literal string.  ] always means start one.  (
always precedes a verb in this example.  (Think of "inputs" as short
for "define-inputs").  ) always ends a sentence.

I have a 15-lesson tutorial on BRL.  You see a paren precede a
non-verb in lesson 15, "where to from here".  (Regarding definition of
"verb", ignore the recent branch of this thread where only statements
are verbs, not expressions; see Paul Prescod's usability concerns
about parens.)

If you expect dollar signs before variable names, commas between
arguments, and semicolons at the end of statments, you might like
PHP.  If you're coming in with no such expectations, you'll like BRL.

If you missed my talk at MIT Friday, slides are available from a shorter
talk I gave previously.

http://brl.sourceforge.net/2000/oscon/