Expression tree
http://msdn.microsoft.com/en-us/library/bb397951.aspx
http://msdn.microsoft.com/en-us/library/bb882637.aspx

Lambda expressions
http://msdn.microsoft.com/en-us/library/bb397687.aspx

Anonymous methods
http://msdn.microsoft.com/en-us/library/0yw3tz5k(VS.80).aspx

Nimrod
AST is part of the specification - this allows a powerful macro system.
http://nim-lang.org/
https://github.com/Araq/Nim

================================================================================

The interpreter assumes that the predefined classes can't be extended.
And optimizes some tests, by avoiding to send a message.

if (this->isBaseClass())
if (this->isSubClassOrEnhanced())

/**
 * Test if an object instance is a true instance of a primitive
 * class.
 *
 * @return true if the object is not a subclass instance or an enhanced one-off.
 */
bool RexxInternalObject::isBaseClass()
{
    return behaviour->isPrimitive();
}


/**
 * Test if an object instance is an enhanced version of a
 * primitive class or a subclass of the primitive class.
 *
 * @return true if the object is a subclass instance or an enhanced one-off.
 */
bool RexxInternalObject::isSubClassOrEnhanced()
{
    return behaviour->isNonPrimitive();
}


class ObjectHeader
{
    ...
    inline bool isNonPrimitive() { return (flags & IsNonPrimitive) != 0; }
    inline bool isPrimitive() { return (flags & IsNonPrimitive) == 0; }
    ...
}


================================================================================

messageSend
called by
    RexxMessage::send                       (MessageClass.cpp), pas de stack
    RexxObject::sendMessage                 (ObjectClass.cpp), pas de stack
    RexxObject::sendWith                    (ObjectClass.cpp), pas de stack
    RexxObject::send                        (ObjectClass.cpp), pas de stack
    macro operatorMethod                    (ObjectClass.cpp), pas de stack
    macro prefixOperatorMethod              (ObjectClass.cpp), pas de stack
    RexxActivation::forward                 (RexxActivation.cpp), pas de stack
    RexxNativeActivation::forwardMessage    (RexxNativeActivation.cpp), pas de stack
    inline RexxExpressionStack::send        (ExpressionStack.hpp), 'this' is the stack
    Interpreter::startInterpreter           (Interpreter.cpp), pas de stack
    Interpreter::initLocal                  (Interpreter.cpp), pas de stack

->send
called by
    ...

->sendMessage
called by
    SendMessageArray                        (ThreadContextStubs.cpp), pas de stack
    SendMessage0                            (ThreadContextStubs.cpp), pas de stack
    SendMessage1                            (ThreadContextStubs.cpp), pas de stack
    SendMessage2                            (ThreadContextStubs.cpp), pas de stack
    RexxArray::sectionSubclass              (ArrayClass.cpp), pas de stack
    RexxArray::operator new                 (ArrayClass.cpp), pas de stack
    RexxArray::of                           (ArrayClass.cpp), pas de stack
    WithSortComparator::compare             (ArrayClass.cpp), pas de stack

=================================================================================

Why this exception on line 2 ?????
This is clearly similar to C++ explicit selection of method
So why not supporting that ???

---------------------
.c1~new~m
.c1~new~m:.c2 -- Message search overrides can be used only from methods of the target object
pause

::class c1
::method m
say "c1::m"
self~m:.c2
self ~ m : .c3

::extension c1 inherit c2 c3

::class c2 mixinclass object
::method m
say "c2::m"

::class c3 mixinclass object
::method m
say "c3::m"
---------------------

RexxInstructionMessage::execute
...
        if (_target != context->getReceiver())  /* sender and receiver different?    */
        {
            /* this is an error                  */
            reportException(Error_Execution_super);
        }
...


RexxExpressionMessage::evaluate
...
        if (_target != context->getReceiver())   /* sender and receiver different?    */
        {
            /* this is an error                  */
            reportException(Error_Execution_super);
        }
...


JLF : getReceiver returns OREF_NULL when sending the message from outside a method
/**
 * Get the message receiver
 *
 * @return The message receiver.  Returns OREF_NULL if this is not
 *         a message activation.
 */
RexxObject *RexxActivation::getReceiver()
{
    if (this->isInterpret())
    {
        return parent->getReceiver();
    }
    return receiver;
}


void RexxObject::messageSend(
    RexxString      *msgname,          /* name of the message to process    */
    RexxObject     **arguments,        /* array of arguments                */
    size_t           count,            /* count of arguments                */
    RexxObject      *startscope,       /* starting superclass scope         */
    ProtectedObject &result)           // returned result
{
    ActivityManager::currentActivity->checkStackSpace();       /* have enough stack space?          */
    /* go to the higher level            */
    RexxMethod *method_save = this->superMethod(msgname, startscope);


RexxMethod * RexxObject::superMethod(
  RexxString *msgName,                 /* target message name             */
  RexxObject *startScope)              /* starting lookup scope           */
{
  return this->behaviour->superMethod(msgName, startScope);
}


JLF : Find a method using the given starting scope information
RexxMethod *RexxBehaviour::superMethod(
    RexxString * messageName,          /* target method name                */
    RexxObject * startScope)           /* starting scope                    */
{
    /* if we have scopes defined and we  */
    /* have a good start scope           */
    if (this->scopes != OREF_NULL && startScope != TheNilObject)
    {
        /* get the scope list for the given  */
        /* starting scope                    */
        RexxArray *scopeList = (RexxArray *)this->scopes->get(startScope);
        if (scopeList != OREF_NULL)        /* have a matching list?             */
        {
            /* get a list of methods             */
            RexxArray *methods = this->methodDictionary->stringGetAll(messageName);
            size_t scopes_size = scopeList->size(); /* get the two array sizes           */
            size_t methods_size = methods->size();
            /* search through the methods list   */
            /* for the first one with a          */
            /* conforming scope                  */
            for (size_t i = 1; i <= methods_size; i++)
            {
                /* get the next method               */
                RexxMethod *method = (RexxMethod *)methods->get(i);
                /* now loop through the scopes list  */
                for (size_t j = 1; j <= scopes_size; j++)
                {
                    /* got a matching scope here?        */
                    if (scopeList->get(j) == method->getScope())
                    {
                        return method;             /* return the method                 */
                    }
                }
            }
        }
    }
    return OREF_NULL;                    /* nothing found                     */
}

================================================================================
use arg with defaults question
================================================================================
http://sourceforge.net/mailarchive/message.php?msg_name=5d74c5720809250931l38055c16u71c5c5df9d33a547%40mail.gmail.com

I see that the following code generates an error:

::method someMethod
use strict arg num = 32, otherNum = -1
...

Incorrect expression detected at "-"

It is easy enough to fix, otherNum = (-1)

I was just surprised. Intuitively, it seems it should work without
the parens. Is this intentional? Something too hard to change in the
parser?

--
Mark Miesfeld


http://sourceforge.net/mailarchive/message.php?msg_name=33bd05330809250951q36e457f4n9212736cb87b37c%40mail.gmail.com

The default expression is what's known as a "constant expression".
The expression must be either a single string or constant symbol
(e.g., a number), or an expression contained in parentheses. This is
a construct used in other places (for example, the forward and raise
instructions). This is an expression syntax that allows additional
subkeyword options to be added without compatibility breakage, since
the parsing of the expression has a clearly defined beginning and end.
That is, it is either a single token, or it is an expression in
parens. An expression like -1 is a prefix operator followed by a
number....two tokens (an operator + the number). This needs to be
specified as either (-1) or "-1", which is a literal token that
doesn't use the prefix operator.

The ::CONSTANT directive had a similar problem. I relaxed the rules
somewhat for that, allowing "+" or "-" followed by a valid numeric
symbol to be used, but I almost regret doing this. This is going to
be extremely difficult to describe what is valid for the directive
because of the special exception. The rules could be relaxed to allow
this in the constant expression case, but I'm very reluctant to do so.

Rick
