Welcome to Software Development on Codidact!
Will you help us build our independent community of developers helping developers? We're small and trying to grow. We welcome questions about all aspects of software development, from design to code to QA and more. Got questions? Got answers? Got code you'd like someone to review? Please join us.
Post History
When you curry or fry a word into a quotation, the word is first placed into a wrapper object. This way, when the quotation is called, it places the word literal back on the stack instead of callin...
Answer
#5: Post edited
- When you curry or fry a word into a quotation, the word is first placed into a `wrapper` object. This way, when the quotation is called, it places the word literal back on the stack instead of calling the word:
- ```
- 1 2 \ + [ ] 3curry ! [ 1 2 \ + ]
- call ! 1 2 + (not 3)
- ```
- My guess is this behavior was predicted to be useful, although in my opinion it is not.
- You could solve this problem by converting wrappers to the objects they wrap...
- ```
- USING: accessors fry parser prettyprint sequences ;
- SYNTAX: syn scan-word '[ _ ] [ wrapped>> ] map . ;
- ```
However it would be easiest to use `1quotation`, which does not wrap anything:- ```
- USING: parser prettyprint quotations ;
- SYNTAX: syn scan-word 1quotation . ;
- ```
- When you curry or fry a word into a quotation, the word is first placed into a `wrapper` object. This way, when the quotation is called, it places the word literal back on the stack instead of calling the word:
- ```
- 1 2 \ + [ ] 3curry ! [ 1 2 \ + ]
- call ! 1 2 + (not 3)
- ```
- My guess is this behavior was predicted to be useful, although in my opinion it is not.
- You could solve this problem by converting wrappers to the objects they wrap...
- ```
- USING: accessors fry parser prettyprint sequences ;
- SYNTAX: syn scan-word '[ _ ] [ wrapped>> ] map . ;
- ```
- However, it would be easiest to use `1quotation`, which does not wrap anything.
- ```
- USING: parser prettyprint quotations ;
- SYNTAX: syn scan-word 1quotation . ;
- ```
#4: Post edited
- When you curry or fry a word into a quotation, the word is first placed into a `wrapper` object. This way, when the quotation is called, it places the word literal back on the stack instead of calling the word:
- ```
- 1 2 \ + [ ] 3curry ! [ 1 2 \ + ]
- call ! 1 2 + (not 3)
- ```
- My guess is this behavior was predicted to be useful, although in my opinion it is not.
- You could solve this problem by converting wrappers to the objects they wrap...
- ```
- USING: accessors fry parser prettyprint sequences ;
- SYNTAX: syn scan-word '[ _ ] [ wrapped>> ] map . ;
- ```
- However it would be easiest to use `1quotation`, which does not wrap anything:
- ```
- USING: parser prettyprint quotations ;
- SYNTAX: syn scan-word 1quotation . ;
```Another approach is to use regular sequence words to build the quotation. This is fine to do before run time, as the stack effect checker can still infer a stack effect.```USING: parser prettyprint sequences ;SYNTAX: syn [ ] scan-word suffix . ;- ```
- When you curry or fry a word into a quotation, the word is first placed into a `wrapper` object. This way, when the quotation is called, it places the word literal back on the stack instead of calling the word:
- ```
- 1 2 \ + [ ] 3curry ! [ 1 2 \ + ]
- call ! 1 2 + (not 3)
- ```
- My guess is this behavior was predicted to be useful, although in my opinion it is not.
- You could solve this problem by converting wrappers to the objects they wrap...
- ```
- USING: accessors fry parser prettyprint sequences ;
- SYNTAX: syn scan-word '[ _ ] [ wrapped>> ] map . ;
- ```
- However it would be easiest to use `1quotation`, which does not wrap anything:
- ```
- USING: parser prettyprint quotations ;
- SYNTAX: syn scan-word 1quotation . ;
- ```
#3: Post edited
- When you curry or fry a word into a quotation, the word is first placed into a `wrapper` object. This way, when the quotation is called, it places the word literal back on the stack instead of calling the word:
- ```
- 1 2 \ + [ ] 3curry ! [ 1 2 \ + ]
- call ! 1 2 + (not 3)
- ```
- My guess is this behavior was predicted to be useful, although in my opinion it is not.
One way to solve this issue is to convert wrappers to the objects they wrap:- ```
- USING: accessors fry parser prettyprint sequences ;
- SYNTAX: syn scan-word '[ _ ] [ wrapped>> ] map . ;
- ```
It would be easiest to use `1quotation`, which does not wrap anything:- ```
- USING: parser prettyprint quotations ;
- SYNTAX: syn scan-word 1quotation . ;
- ```
- Another approach is to use regular sequence words to build the quotation. This is fine to do before run time, as the stack effect checker can still infer a stack effect.
- ```
- USING: parser prettyprint sequences ;
- SYNTAX: syn [ ] scan-word suffix . ;
- ```
- When you curry or fry a word into a quotation, the word is first placed into a `wrapper` object. This way, when the quotation is called, it places the word literal back on the stack instead of calling the word:
- ```
- 1 2 \ + [ ] 3curry ! [ 1 2 \ + ]
- call ! 1 2 + (not 3)
- ```
- My guess is this behavior was predicted to be useful, although in my opinion it is not.
- You could solve this problem by converting wrappers to the objects they wrap...
- ```
- USING: accessors fry parser prettyprint sequences ;
- SYNTAX: syn scan-word '[ _ ] [ wrapped>> ] map . ;
- ```
- However it would be easiest to use `1quotation`, which does not wrap anything:
- ```
- USING: parser prettyprint quotations ;
- SYNTAX: syn scan-word 1quotation . ;
- ```
- Another approach is to use regular sequence words to build the quotation. This is fine to do before run time, as the stack effect checker can still infer a stack effect.
- ```
- USING: parser prettyprint sequences ;
- SYNTAX: syn [ ] scan-word suffix . ;
- ```
#2: Post edited
Use `1quotation`:- ```
USING: parser prettyprint quotations ;IN: syn-trySYNTAX: syn scan-word 1quotation . ;- ```
Another way:- ```
USING: parser prettyprint sequences ;IN: syn-trySYNTAX: syn [ ] scan-word suffix . ;```If you need to build a more complex quotation, you can do something akin to this:- ```
- USING: parser prettyprint quotations ;
IN: syn-try<< SYNTAX: syn scan-word 1quotation '[ 1 2 @ ] . ; >>syn +- ```
Result:`[ 1 2 + ]`
- When you curry or fry a word into a quotation, the word is first placed into a `wrapper` object. This way, when the quotation is called, it places the word literal back on the stack instead of calling the word:
- ```
- 1 2 \ + [ ] 3curry ! [ 1 2 \ + ]
- call ! 1 2 + (not 3)
- ```
- My guess is this behavior was predicted to be useful, although in my opinion it is not.
- One way to solve this issue is to convert wrappers to the objects they wrap:
- ```
- USING: accessors fry parser prettyprint sequences ;
- SYNTAX: syn scan-word '[ _ ] [ wrapped>> ] map . ;
- ```
- It would be easiest to use `1quotation`, which does not wrap anything:
- ```
- USING: parser prettyprint quotations ;
- SYNTAX: syn scan-word 1quotation . ;
- ```
- Another approach is to use regular sequence words to build the quotation. This is fine to do before run time, as the stack effect checker can still infer a stack effect.
- ```
- USING: parser prettyprint sequences ;
- SYNTAX: syn [ ] scan-word suffix . ;
- ```
#1: Initial revision
Use `1quotation`: ``` USING: parser prettyprint quotations ; IN: syn-try SYNTAX: syn scan-word 1quotation . ; ``` Another way: ``` USING: parser prettyprint sequences ; IN: syn-try SYNTAX: syn [ ] scan-word suffix . ; ``` If you need to build a more complex quotation, you can do something akin to this: ``` USING: parser prettyprint quotations ; IN: syn-try << SYNTAX: syn scan-word 1quotation '[ 1 2 @ ] . ; >> syn + ``` Result: `[ 1 2 + ]`