ianmccr

190 Reputation

6 Badges

18 years, 100 days

MaplePrimes Activity


These are replies submitted by ianmccr

@tomleslie 

 I have tried you sample and it works.  My goal here is to set up the environment for a clifford algebra which uses a procedure to define dimension, minindex, maxindex, and a table representing the metric.  I intended to include calls to addspace at the end of the module so it would Ioad the metrictable with four or five different calls to a local procedure Assignspace(Dim,table['identity'] or the like).  This way the user can choose the metric environment to be used.  Then the call to GetSpace would set up the default environment when the module loads. (Something like the programming sample diffimpl does to create a database of functions for use by the parser.)  I am still trying to get a handle on the evaluation rules and  I didn't catch the syntactic distinction between evauluating a procedure and executing it.  Thank you for clarifying the rules for me.

I have attached a worksheet, but this is the code I was testing.testmodule.mw

restart;
Glyph2 := module()
    export    AddSpace, GetSpace, RemoveSpace,DoSpace;
    local     MetricTab;

    MetricTab := table():

    AddSpace := proc( theName::symbol, implementation )
        local    old_imp;
        old_imp := NULL;
        if assigned( MetricTab[ theName ] ) then
            WARNING( "replacing existing extension `%1'", theName );
            old_imp := eval( MetricTab[ theName ] )
        end if;
        MetricTab[ theName ] := eval( implementation, 1 );
        eval( old_imp, 1 )
    end proc;

    RemoveSpace := proc( theName::symbol )
        if assigned( MetricTab[ theName ] ) then
            MetricTab[ theName ] := evaln( MetricTab[ theName ] )
        end if;
        NULL
    end proc;

    GetSpace := proc( theName::symbol )
        if assigned( MetricTab[ theName ] ) then
            eval( MetricTab[ theName ], 1 )
        else
            NULL
        end if
    end proc;
    AddSpace('default','proc() print("Metric is default")end proc');
    GetSpace( 'default');   
end module:
eval(Glyph2:-GetSpace('default'));

I ordered the book from Amazon after I read the post.  The book is full of useful insights that are hard to glean from the help files. I particularly appreciated Appendix B, which summarized the rules for terminating maple language statements. One tends to pick this up by osmosis, but having a summary of the rules for current and older versions of maple is welcome. While the information is probably included in the help files, I wasn't able to find a help page discussing terminating characters in particular.

@Carl Love 

" I fear that you don't have the module "spirit" yet. "  I'm afraid you're correct.  I'm moving forward using code that was written for Maple V and am not quite at the present yet.  All those globals did bother me, but I wanted to have a module that worked so I could play with the code and get a feel for current versions of Maple by experimentation. You're advice is  a helpful start.

@Mac Dude   Maple language does have a steep learning code, but given time, the interpretive capability of the language is its own teaching aid. I agree that the programming guide is excellent, but it is a little disconcerting when I encounter examples,such as the above, that don't work as expected. From an outside perspective, I find it difficult to assess Maplesoft's roadmap for the language. I have been poking through code that was written in the late 90's for Maple V, but, so far, I haven't come across any comparable  public code for applications written after the introduction of modules from which I could gleen effective coding styles. Similarly, I haven't seen a general maple programming book that post-dates MapleV.  Maple is obviously still a dynamic application, but it seems to have moved away from its original role.

@Mac Dude 

Thank you.  I was unaware of the idiosyncrasies of the 2D input parser. This resolves my issue completely. Are there any general maple programming reference books which reflect more modern versions of Maple? I have been using Maple: An Introduction and Reference based on Maple V together with the programming guide.

1 2 3 4 Page 4 of 4