control-toolbox / CTBase.jl

Fundamentals of the control-toolbox ecosystem
http://control-toolbox.org/CTBase.jl/
MIT License
10 stars 2 forks source link

Lift #201

Open ocots opened 1 month ago

ocots commented 1 month ago

A lift of a function should return a function.

ocots commented 1 month ago

En fait, cela ne permet toujours pas de faire :

F(x) = 2x
H = Lift(F)
H(t) = H(t, t)

On a une erreur :

julia> H(t) = H(t, t)
ERROR: cannot define function H; it already has a value
Stacktrace:
 [1] top-level scope
   @ none:0
 [2] top-level scope
   @ REPL[6]:1

En fait, on peut faire (et on pouvait déjà faire) :

F(x) = 2x
H(x, p) = Lift(F)(x, p)
H(t) = H(t, t)
jbcaillau commented 1 month ago

@ocots agreed. the allowed / forbidden combinations are:

julia> f = 1
1

julia> f(x) = 2
ERROR: cannot define function f; it already has a value
Stacktrace:
 [1] top-level scope
   @ none:0
 [2] top-level scope
   @ REPL[64]:1

julia> f = x -> 2
#123 (generic function with 1 method)

julia> g(x) = 3
g (generic function with 1 method)

julia> g = 4
ERROR: invalid redefinition of constant Main.g
Stacktrace:
 [1] top-level scope
   @ REPL[67]:1

julia> g(x, y) = 4
g (generic function with 2 methods)

A function (not a functional value, aka lambda) can have several definitions (multiple dispatch).

Regarding Poisson, not clear from the PR whether we can completely bypass the Lift constructor and bracket mere functions of x and p?