Project

General

Profile

Support #69

MathT.Mod

Added by Patrick Hunziker 8 months ago. Updated 8 months ago.

Status:
New
Priority:
Normal
Assignee:
-
Category:
Compiler

Description

Modules MathX have low level code, and a compiler switch.
Is there a preferred approach on converting it them to one generic templated module ?
Or would it be preferrable to just have an almost empty module that just aliases to one of several imported modules, like
Math32, Math64, Math16, Math... ?
Could/should the compiler or the compiler switch do such aliasing, avoiding rewriting such code ?

MODULE Math (TYPE Datatype);    
...
END Math
<pre/>

History

#1 Updated by Florian Negele 8 months ago

We are currently considering to support specialisations of template modules. The basic idea is have a generic module with one ore more template parameters as in your example, but also allow users to provide a so-called specialised module which fixes one ore more template parameters to a certain type or value. This specialisation is chosen over the generic version whenever its template arguments provide a better match when importing.

Regarding your example, such specialisations might look as follows:

MODULE Math (TYPE Datatype); (* generic version *)
...
END Math.

MODULE Math (FLOAT32); (* specialised version *)
...
END Math.

MODULE Math (FLOAT64); (* specialised version *)
...
END Math.

The specialised modules are completely ordinary modules in this case and not subject to template instantiation but are still available for importing using template arguments.

#2 Updated by Patrick Hunziker 8 months ago

I like the idea

#3 Updated by Patrick Hunziker 8 months ago

might require defining datatype in header to make it accessible in code ?

MODULE Math (TYPE Datatype); (* generic version *)
...
END Math.

MODULE Math (TYPE Datatype=FLOAT32); (* specialised version *)
...
END Math.

MODULE Math (TYPE Datatype=FLOAT64); (* specialised version *)
...
END Math.

#4 Updated by Felix Friedrich 8 months ago

  • Category set to Compiler

Also available in: Atom PDF