-
Notifications
You must be signed in to change notification settings - Fork 743
-
Notifications
You must be signed in to change notification settings - Fork 743
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
Can one determine if an optional inline command argument has been provided #2163
Comments
Sorry, accidentally clicked on "Close issue". I was about to write that there are different criteria for function comparison. Since what you're comparing are two lambdas, they'll always be different from each other even if their code content looks the same, as their context is necessarily different. On the other hand, if you assigned a function to a variable and then compared it against itself, you'd get "true": This also works for copies: |
@ToonTalk You can't check if a ring is empty in Snap!, but you can with javascript. Here's a helper block that does just that: |
About inline vs. C-shaped: We use inline in primitives, such as RUN, in which we expect the actual input expression to be a variable rather than a constant script. We use C-shaped in all other contexts, for which the actual input is likely to be a specific constant script. In general, there is no way to compare two procedures for EQUAL?-ness. We follow Scheme in this; the idea is that two procedures might well be functionally equivalent even if their texts are different, e.g., if they have different formal parameters but are otherwise the same, or even if the texs are exactly the same, but they were defined in different environments and use a free variable. If you think of a procedure as representing a function, two procedures might have altogether different algorithms that produce the same result; my standard example is f(x)=2x+6; g(x)=2(x+3). So we can only realistically test for EQ?-ness. On our short-term list is a way to get the text of a lambda expression, so you'll be able to test two texts for EQUAL?-ness, at your own risk with respect to defining environments. |
By the way I see that if I change an argument from inline to c-shape then existing code still works just has redundant rings. But if I change a c-shape argument to inline the command is lost. Would it be wrong to ringify it? |
Ringifying is probably the right thing. 0 for an empty script is definitely the wrong thing! I hereby declare that a bug. |
There's a lot of edge cases around changing types. Duplicate of #581
This feels like an artifact of JS type coercion. :( At least JS's type rules have a spec. I think inline rings are more like default values, unfortunately. It's worth mentioning that an empty command ring will pass the type test of This is another use case for introspection! |
I tried this
but the = predicate reported false.
Generally is the following right?
Perhaps related to #1204
Generally I'm unclear about best practice regarding using inline commands versus c-shaped for command arguments
The text was updated successfully, but these errors were encountered: