Skip to Content.
Sympa Menu

mathemagix-devel - [Mathemagix] Convention changes for automatic converters

Subject: Mathemagix

List archive

[Mathemagix] Convention changes for automatic converters


Chronological Thread 
  • From: Joris van der Hoeven <address@concealed>
  • To: address@concealed
  • Subject: [Mathemagix] Convention changes for automatic converters
  • Date: Mon, 28 Jul 2008 11:15:22 +0200

Hi all,

I just operated some changes concerning automatic converters.
First of all, the following renamings took place:

define_converter -> define_rewriter
define_caster -> define_converter
cast -> convert

The old left-and-right-transitive converters (corresponding to
'define_converter' and 'convert') are deprecated. For internal use,
I temporarily keep define_rewriter, but this should never be
used by others. The new converters designated by 'convert'
are neither left or right-transitive.

I also swapped the semantics of upgrader and downgrader:
from now on upgraders are left-transitive (i.e. for a converter
A ~> B and an upgrader B ~> C, we automatically generate
a converter A ~> C) and downgraders are right-transitive.
Since upgraders tend to have more complex right-hand sides,
this is a relief for the compiler, since pattern matching
can take place on the right-hand side. Conversely,
downgraders usually have complex left-hand sides.
In fact, the change in semantics usually goes unnoticed
for the user: in practice, people tend to use either
chains of upgraders or chains of downgraders.

Finally, the operator 'cast' has been introduced for
a different purpose: it is used for explicit casting,
based on the syntax expr :> T. Whenever the compiler
(not implemented in the old interpreter mmx-light)
encounters an expression expr :> T, we first attempt
a conventional conversion. In case of failure,
we try to convert the expression cast (expr) to T.
Return values of functions and other language constructs
for which the return type is known also use the casting mechanism.

I performed all necessary renamings in all packages.
Please let me know about possible bugs.

Best wishes, Joris


  • [Mathemagix] Convention changes for automatic converters, Joris van der Hoeven, 07/28/2008

Archive powered by MHonArc 2.6.18.

Top of Page