-
Notifications
You must be signed in to change notification settings - Fork 0
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
Feature.lambdas #34
Feature.lambdas #34
Conversation
Nice, @jneen! As an exercise, I'd like to see what this would look like for a real example. I think it will be instructive for anything else we need and to show how this will work once it's handed to config. For example, in https://github.com/opencounter/opencounter/issues/3202 Jeff describes a fee structure that is based on the number of hours the event lasts per day. The fee is charged as follows: each hour the event takes place costs $175, with a minimum 4h charge per day. In other words, there is a minimum charge of $700 per day for the first four hours, and then any hour above that is an additional $175 per hour. Would a function that calculates that fee look something like this?
(Assumes a function
|
DEPRECATES calling #dependencies with an argument.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
@@ -28,30 +28,18 @@ class Addition < Arithmetic | |||
def operator | |||
:+ | |||
end | |||
|
|||
def self.precedence |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
did we stop needing this after the parser rewrite?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yep! Precedence is now hardcoded in the parser, which is honestly where it should live.
require_relative 'case/case_when' | ||
require_relative 'case/case_then' | ||
require_relative 'case/case_switch_variable' | ||
require_relative 'case/case_else' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How are we able to delete all these case child nodes?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Leftover from the parser
Something similar to this!
This could now be theoretically written in Dentaku as well.
Fixed the example, the initial value should be passed in. The type can be any type, just must be the same as the initial value and the result. |
If I'm honest, I want to start by introducing |
Lambdas and accessor syntax!
Adds lambda syntax as follows:
as well as three functions that use them:
This also introduces accessor syntax for structs and certain declared types:
In order to register a declared type as having struct accessors, we must use the
structable
declaration in the declared type: