How to redefine standard operators

Hello,
is there a way to give new properties to built-in operators, such as `+` or `*`?
For example, I have my own type MYTYPE and procedure for adding MyAdd(a::MYTYPE, b::MYTYPE). Now, I would like to use: a + b instead of MyAdd(a,b). Is it possible?

Thank you.
Karel

gkokovidis's picture

How to redefine standard operators

Look at the "alias" and "macro"commands and see if they will do what you want.

>?alias
>?macro

Regards,
Georgios Kokovidis

Thank you, but I believe

Thank you, but I believe this is not the way.
Karel

See overload

I think this can be done with overload.
See ?overload.

Hope this helps,

Thomas

Thank you. That's it. Karel

Thank you. That's it.
Karel

I know that the option

I know that the option "overload" can be used in Maple10 (maybe also Maple9).
Is it possible to also overload operators in older Maple versions (for example Maple8)?
Thank you
Karel Srot

Don't Know

I started using Maple at version 9.5 so I don't know.
I noticed that some of the people that would know have
missed the post so I am answering to bump it up to the
top. Hopefully they will take notice. If you don't
get a response I would repost it.

Thomas

overload

The ability to rebind operators, such as +, was introduced in Maple 6; however, the overload option (and procedure) was introduced in Maple 9.5.

JacquesC's picture

How newcomers to Maple can find this information

Very helpfully, all the "What's New" pages dating back for ages are in the help pages. These are called "updates" in the help system. You can do a full-text search for keywords (like overload) and look at the hits in those updates pages to find out when particular features were introduced (or modified).

Some of the most useful information about Maple can only be found there -- for example, the only known example (to me!) for using some of the profiling tools introduced in Maple 6 is in the What's New for Maple 6. Sometimes there is better information in the What's New than in the actual help pages for the feature(s)!

what's old

It would be useful to have a table/page listing Maples features by release. This seems a case where a wiki would be ideal---easy for someone to start, and convenient for others to fill in the details and update.

JacquesC's picture

Where is Will when you need him?

Yep, that Wiki sure would be nice.

Will's picture

Wikia

I just put in a request for Wikia to create a new wiki for Maple.

Wikia is a wiki hosting service that runs on the same software as Wikipedia, so it should be quite useful for what you want. I will let the community know once the Wiki is available.

(I guess this comment, about the Maple Wiki, is the one putting me over the edge to 700)

____
William Spaetzel
MaplePrimes Administrator
Software Developer, Maplesoft

700

Congrats on your 700th post and thanks for pursuing the wiki. It should be interesting.

JacquesC's picture

Go for 715

Come on Will, you're so close now, I am sure you can find an excuse to get yourself 15 more points. Blog some, respond to queries, etc. It would be nice to see someone else at the top of the list!

A Ruthian Effort

I hadn't noticed, until now, the actual number. 714. A fitting goal. For those not familar with baseball, it was Babe Ruth's career home run total.

JacquesC's picture

512

That comment of yours had you at 512 (and that will likely change very quickly...). But what a nice round number that is!

hah

A Knuthian effort!

Please, can you write a short example

Please, can you write a short example which shows how to overload an operator in Maple 6 (or later). Thank you.
Karel Srot

I found it. :-) Thank you.

I found it. :-) Thank you.

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
}