Open jougs opened 7 years ago
This indeed looks very handy!
Hello, I advocate to reuse the existing syntactical style. The @jougs proposal misses for example the type of the tau. The syntax looks like C++ templates, but it is hardly related to it (and at least for me is confusing therefore). Thus, it is not possible to check the type correctness of the expression on the righthand side.
I composed several alternative which (imho) don't have these disadvantages. However you can still make your own proposals.
equations:
# 1
shape alpha(tau ms) = (e / tau) * t * exp( -t / tau)
# 2
function alpha(tau ms) = (e / tau) * t * exp( -t / tau)
# 3
shape alpha(tau ms):
return (e / tau) * t * exp( -t / tau)
end
function I_syn_ex pA = convolve(alpha(tau_syn_ex), spikes_ex)
function I_syn_in pA = convolve(alpha(tau_syn_in), spikes_in)
end
or as an external block:
# 4
shape alpha(tau ms):
return (e / tau) * t * exp( -t / tau)
end
# 5
shape alpha(tau ms):
(e / tau) * t * exp( -t / tau)
end
equations:
function I_syn_ex pA = convolve(alpha(tau_syn_ex), spikes_ex)
function I_syn_in pA = convolve(alpha(tau_syn_in), spikes_in)
end
@DimitriPlotnikov: I like your suggestion #1
most. Clear and simple.
@DimitriPlotnikov I think the proposition from @jougs had the advantage that the < . >
markers made it standout from the rest, so you can immediately notice that it is a shape with parameters.
It indeed reuses the same structure as c++ templates, but I don't really see how anyone might confuse the two given the context...
On the other hand, using the parentheses make it look as if alpha
is in fact a function of tau
here...
Between all suggestions, I would thus prefer the one from @jougs , then your #1
, but especially not #2
which might confuse users a lot, I think.
Alternatively, we could use other notations as [ . ]
or { . }
to avoid the ambiguity...
We can use the one from @jougs, but then as:
shape alpha<tau ms> = (e / tau) * t * exp( -t / tau)
In order to make
shape
declarations more generic and re-usable, I think it would be nice to support a new notation in addition to the existing notation. The new notation should allow to parametrize theshape
with one or more variables. Here is an example of what this could look like:@ingablundell, @DimitriPlotnikov, @Silmathoron