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

local (named (gasp / controversial)) parameters to a defined word #14

Closed
nmorse opened this issue Sep 19, 2018 · 3 comments
Closed

local (named (gasp / controversial)) parameters to a defined word #14

nmorse opened this issue Sep 19, 2018 · 3 comments

Comments

@nmorse
Copy link
Owner

nmorse commented Sep 19, 2018

(e.g.
[m:number x:number b:number]
[m x * b +] [my-linear-function]
define-with-named-args
)
or how to implement the quadratic formula.

@nmorse
Copy link
Owner Author

nmorse commented Sep 19, 2018

Even if named vars can be considered (a bite out of pure point-free).

# discriminant (with locally named args)
2 3 4 quo [c] def quo [b] def quo [a] def
b dup * 4 a * c * -
# >>> -23
## but the problem is that we really don't want args defined globally, so...
[a b c] [b dup * 4 a * c * -] [discriminant] define
2 3 4 discriminant
# >>> -23

The alternate pure point-free is a tangle of stack shufflers.

@nmorse
Copy link
Owner Author

nmorse commented Sep 21, 2018

[a b c op] [b -1 * b b * 4 a * c * squareroot  op 2 a * /] [quadratic-crossing]
[a b c] [a b c discriminant dup 0 < [[]] if dup 0 > [[ a b c [+] quadratic-crossing] ...] [] if-else] [quadratic]

manageable with the local-defined values (words) , but the stack swapping version is too complex to show here.

@nmorse
Copy link
Owner Author

nmorse commented Dec 12, 2018

since define has matured into a useful construct with local-words, adding named-args
(e.g. named-args:[x y]) to consume stack arguments into getters to be used in the definition and local-words seem like an interesting enough idea to pursue.

{named-args: [a b c]
 local-words: { discriminant: [ ... ] quadratic-crossing: [ ... ] ... }
 definition: [a b c discriminant dup 0 < [[]] if dup 0 > [[ a b c [+] quadratic-crossing] ...]
} [quad] define

@nmorse nmorse closed this as completed Dec 16, 2018
Language Dev automation moved this from In progress to Done Dec 16, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Language Dev
  
Done
Development

No branches or pull requests

1 participant