Fw: [moto-devel] Re: Motopolitics.

"Charles Patterson" <cpatterson-N2D8602I6TJWk0Htik3J/[email protected]> Fri, 24 Jan 2003 13:46:41 -0500
Newsgroups gmane.comp.lang.moto.devel
Message-ID <003501c2c3d8$f22294a0$8b14a8c0@cpatterson>

> > A layer may be a better route than a series of
> > extensions.

> Not to sound argumentative :) but I don't really follow this line of
> reasoning (or maybe we are getting bogged down in our different
> terminology and how we each look at things). I'm just trying to
> understand exactly what you are saying.

> A layer or a series of extensions... to me there's really no difference.
> The extensions are built using moto's internal functions and C and are
> available as objects in moto space.

OK.  I'm assuming "extensions" basically means a library, much like any C or
C++ library.  You have a set of functions (or objects) and some enum types.
Then you program with it.  Think C sockets or threads.  Or, for my example,
regular expressions.  Here would be an example regex parse in C++ (I have
never done a real regexp in C++, but I think this example will suffice):

    RegExp E;
    vector<string> matches;

    E = RegExp( "\d+[a-z]" );
    E.caseSensitive = false;

    matches = E.Parse( myString );
    if ( matches.Size == 0 || matches.Size() > 1 ) return error;
    printf( "Match = %s", matches[ 0 ] );
    matches.clear();

Using the basic C++ class system, including cool overloading, this is about
the best I can do in conciseness.  But suppose I will be working with
regexes a lot.  Instead of creating a RegExp, I would like to be able to do
an 'in-line' constant one.  Adjusting the above, I wouldn't need to set up
the RegExp E:

    matches = E.Parse( /\d+[a-z]/i, myString );

To do this, I need to be able to create a new syntax for constant expression
of type RegExp which is designated by surrounding a string in slashes (and
also allowing for modifier chars after the trailing slash).  Continuing, I
could extend the idea of a vector<string> and the parse rules of C++ and
maybe pull this off:

    { match } = myString ~= /\d+[a-z]/i || error;

When myString matches the pattern, it will return a vector of strings.  In
turn, I have here a vector whose indices are named, but in this case there
is only one named part (match) as I expect one match.  If the assignment
from vector to vector has more than one part, I expect an error which is
caught by the || syntax.  (There are Perl people here, right?  (-:  Sorry to
slaughter the language.  It's been a while.)

Is this too much?  If you do lots of string comparison it may be worth it.
How many C++ rules did I violate?  My point is that a library wouldn't be
able to do this kind of syntactic "extension" so I'm calling it a "layer" as
I'm assuming David meant it.  You would need a stronger language layer to
parse down to Moto-layer0 to accomplish this.

> Now all of this could be shipped with Moto and turned on and off when
> you configure the source (like ./configure --enable-webspace). It's not
> part of the core language however, and this is where I think we are not
> understanding each other.

Right.  I understand the value of that.  And it would be cool to turn on and
off layers as defined now in the same way!  The question is, is it even
worth dreaming up something like above?  Staying sketchy on details, I'd
imagine the web world could use regular expressions, and a host of other
trickery regarding odd scoping (page, site, session), and, for making a
forms page build more like a gui, probably something akin to callbacks and a
way to connect html fields to variables.

So back to one of my odd points, it would be wild if, instead of layers (as
I'm defining it here), Moto could allow syntax add-ins from the embedding
environment.  It's kind of the same thing.  Probably very hard, but also
very cool.  I don't know a language like that!