Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

"Simplify" overloading functions #488

Closed
5 tasks done
Nelson-numerical-software opened this issue Aug 8, 2021 · 6 comments
Closed
5 tasks done

"Simplify" overloading functions #488

Nelson-numerical-software opened this issue Aug 8, 2021 · 6 comments
Assignees
Milestone

Comments

@Nelson-numerical-software
Copy link
Collaborator

Nelson-numerical-software commented Aug 8, 2021

Currently, overloading is powerfull but not easy to manage.
To overload an operator, we need to manage many combination of types
example:
1 + 'c' requires to create double_plus_char function
A better (?) more compatible way could be to manage ONLY one type.

double_plus_char.m --> @double/plus.m

in plus.m we force types

function r = plus(a, b)
 A = double(a);
B = double(b);
r = A + B
end
  • path search need to modified to search first overloaded functions
  • do we consider overload of native types ? (example double overload or not ?)
    example: To allow to overload double can be "dangerous". It can break all existing code insidiously.
    It can also to be "slow" check each basic type will have a cost.
    Currently in Nelson, overload can "very" slow if overload is overloadbasictype(true)

overload with basic types could also have interesting use for code generation.
But we can also create special types to manage it.
example: 'Double'

  • how to manage overloading with builtin (mex will be as functions)
    We can mangling function name for builtin: internal name could be @double/plus or @double:plus
    function will be never callable directly

  • default behavior: What do we do if methods are not defined? Do we call default method ?

  • reworks all existing overloaded functions to manage new overload algo

Test case: myComplex object with overload

@myComplex.zip

Why not directly move to classdef object in nelson ?
with this basic overload we can manage many cases.
classdef have advantage to have all overload method in same file but initial algo are same.
classdef will be considered later (certainly after v1.0)

@Nelson-numerical-software
Copy link
Collaborator Author

Need to be explored:
creates a function 'function t = toto(a)'
and an overload @int32/toto
and try to call 'toto(int32(9))'

@Nelson-numerical-software Nelson-numerical-software removed this from the v0.6.2 milestone Feb 5, 2022
@Nelson-numerical-software
Copy link
Collaborator Author

Nelson-numerical-software commented Feb 5, 2022

"first we need to have #491"
In fact, only define function_handle as a true type was enough (done)

@Nelson-numerical-software
Copy link
Collaborator Author

Nelson-numerical-software commented Jun 26, 2023

a poc was released and working. Need to be industrialized (in progress)

@Nelson-numerical-software
Copy link
Collaborator Author

In progress, on private branch

@Nelson-numerical-software
Copy link
Collaborator Author

Nelson-numerical-software commented Jul 30, 2023

A reminder about in progress

  • add class type and use it
  • add function_handle type
  • reorganize types
  • simplify validators module
  • simplify operators
  • vertcat
  • horzcat
  • isequal, ...
  • sparse merge
  • default class overload (as handle that already implemented)
  • add overload level compatibility choice
  • rework lookupFunction with new existing poc
  • merging overloaded functions

Nelson-numerical-software added a commit that referenced this issue Sep 3, 2023
allows to overload all types including basic types (as double :p)
Nelson-numerical-software added a commit that referenced this issue Sep 4, 2023
allows to overload all types including basic types (as double :p)
Nelson-numerical-software added a commit that referenced this issue Sep 4, 2023
allows to overload all types including basic types (as double :p)
Nelson-numerical-software added a commit that referenced this issue Sep 4, 2023
allows to overload all types including basic types (as double :p)
Nelson-numerical-software added a commit that referenced this issue Sep 4, 2023
allows to overload all types including basic types (as double :p)
Nelson-numerical-software added a commit that referenced this issue Sep 4, 2023
allows to overload all types including basic types (as double :p)
Nelson-numerical-software added a commit that referenced this issue Sep 4, 2023
allows to overload all types including basic types (as double :p)
Nelson-numerical-software added a commit that referenced this issue Sep 5, 2023
allows to overload all types including basic types (as double :p)
Nelson-numerical-software added a commit that referenced this issue Sep 5, 2023
allows to overload all types including basic types (as double :p)
Nelson-numerical-software added a commit that referenced this issue Sep 5, 2023
allows to overload all types including basic types (as double :p)
Nelson-numerical-software added a commit that referenced this issue Sep 6, 2023
allows to overload all types including basic types (as double :p)
Nelson-numerical-software added a commit that referenced this issue Sep 6, 2023
allows to overload all types including basic types (as double :p)
Nelson-numerical-software added a commit that referenced this issue Sep 7, 2023
allows to overload all types including basic types (as double :p)
Nelson-numerical-software added a commit that referenced this issue Sep 7, 2023
allows to overload all types including basic types (as double :p)
Nelson-numerical-software added a commit that referenced this issue Sep 7, 2023
allows to overload all types including basic types (as double :p)
@Nelson-numerical-software
Copy link
Collaborator Author

this feature took some time but it's just a first step.
LGTM

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant