Rank: Newbie
Groups: Registered
Joined: 13/04/2024(UTC) Posts: 3
|
smath function bug.sm (6kb) downloaded 2 time(s).I ran into this issue on a really long calc and took me a while to realize what went wrong. When I have a function with constants in it, I can redefine the constants later and call the function and it works great. But if I redefine the function, this functionality stops working. I also tried renaming the second function definition and/or adding another term to the function signature and this didn't give me the expected behavior. Not sure if this is already known or what's going on, but thought I'd make an account and post it. Thanks everyone. Love Smath. Edited by user 13 April 2024 04:30:59(UTC)
| Reason: Not specified
|
|
|
|
Rank: Newbie
Groups: Registered
Joined: 13/04/2024(UTC) Posts: 3
|
Whoops I didn't have the file right to demonstrate the bug. Now it shows the issue as intended.
|
|
|
|
Rank: Advanced Member Groups: Registered
Joined: 23/03/2016(UTC) Posts: 278 Was thanked: 91 time(s) in 57 post(s)
|
I don't believe this is a bug. When you first define the function. c.1 and c.2 are undefined. So you can define c.1/c.2 outside of the function at will and it will calculate fine. However, when you redefine the function, values for c.1/c.2 are already defined so these get evaluated and assigned in the function. There are couple ways to deal with this. 1. Add c.1, c.2 to the input variables. So f(i,j) becomes f(i,j,c.1,c.2) 2. Clear c.1, c.2 before re-defining the function. That being said, I don't quite understand the use case for redefining functions within a sheet or changing values of constants. If you're changing the value of a constant, it isn't a constant and should become a function variable. smath function (not a) bug -alyles.sm (7kb) downloaded 4 time(s). |
|
|
|
|
Rank: Newbie
Groups: Registered
Joined: 13/04/2024(UTC) Posts: 3
|
Ah thank you alyles. I know I could work around this by adding these non-constants to the function signature. It was what I viewed as inconsistent behavior that bothered me. However, I see from your explanation that the behavior changes not based on whether the function is redefined, but whether the "constant" in the function is defined before or after the function. Ie, if in my sample file you define c1 at the top of the page, the function doesn't update it's value based on c1 changed till you repaste the function. I'm content that that is consistent program behavior, if a smidge confusing. Thank you! Edited by moderator 13 April 2024 05:28:01(UTC)
| Reason: marked as SOLVED (not a bug)
|
|
|
|
Forum Jump
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.