Comments (4)
After a short analysis, I am not still not sure if it is a compiler limitation (most probably) or just a bug.
The core issue is that switch
(like most other control flow functions when compiled) requires a static block as second argument. If you provide a dynamic one (like here generating it with reduce
), you are on your own, as the compiler cannot statically analyze what switch
will get as second argument anymore. In such case, it may work without issue, or not, depending on what you provide.
I will do a more in-depth investigation in the next days to get to the bottom of it, though, in the meantime, you can use at least two workarounds:
- Set explicitly
deltaStream
value when cloning the object:
deltaItr: make deltaIterator [deltaStream: 100]
- Force the binding of the
reduce
argument block to the local object:
switch deltaStream bind reduce [...] self
Anyway, I am working on deprecating the high-level compiler partially (or completely), so that all provided Red code will be directed to the interpreter, getting rid of those problematic static/dynamic combos edge cases for the compiler. Such cases can be solved but the increase in complexity in the compiler internals is just not worth the effort. They are better (cleaner, faster, shorter) ways.
from red.
It doesn't make sense to me that switch takes a static block, I expected it to bind to the self by default (which would match interpreted). Your work around #2 does work however #1 doesn't: deltaItr: make deltaIterator [deltaStream: 64]
has the same "no value" error. The reason the value 100 didn't fail is because the switch statement doesn't match and therefore the deltaStream value is not accessed.
I'm guessing by "high-level compiler" you mean compiling ahead of time instead of JIT. Being able to do redc -e -r
is pretty fundamental to distribution but AOT vs JIT doesn't make much difference. I wouldn't mind redc -c
being removed and -e
being the new default. AOT would be better but maybe it contradicts Red design at a fundamental level such that it would never be possible (or maybe just impractical).
from red.
After a deeper analysis, I confirm that it is a compiler limitation: the deltaStream
word in the reduce
argument block is stored (along with that block) in redbin format with a binding to an empty context, as the compiler in the above case compiles the objects entirely into code, so that the compiled context and the one stored in redbin format are not linked together. The result is that the inner deltaStream
is pulling its value from an empty context in redbin format where all the fields are unset.
It doesn't make sense to me that
switch
takes a static block
I should have used "literal" instead of "static" there to avoid misunderstanding.
The reason the value 100 didn't fail is because the switch statement doesn't match and therefore the deltaStream value is not accessed.
You're right, I've missed that, sorry.
I'm guessing by "high-level compiler" you mean compiling ahead of time instead of JIT
I meant the Red to Red/System compiler which is currently an AOT one. In the future, we will have a JIT one, which is a much better fit for Red semantics.
Being able to do redc -e -r is pretty fundamental to distribution
We're keeping that of course.
AOT would be better but maybe it contradicts Red design at a fundamental level such that it would never be possible (or maybe just impractical).
That's exactly right.
from red.
I will leave that ticket open with the "wontfix" status until we drop the Red compiler. Once that done, we'll close all the "type.compiler" tickets all together.
from red.
Related Issues (20)
- WindowsXP compile target does not work for any source: error in draw-gdi.reds, in function: exec/gui/draw-begin
- VID actors syntax errors are not caught
- Native builds do not run under Windows XP even with WindowsXP target: calls D3D11 which is not supported on XP HOT 5
- Promotion inconsistency in `min/max pair float`
- Using point2D! as SIZE for a TAB-PANEL makes its children not to be shown.
- GROUP-BOX frame is not always conforming to its size. HOT 3
- view in 0.65 : word result is not local
- False Positive! HOT 1
- Inside part of TAB-PANELs do not resize. HOT 2
- Extra slashes in file/url composition
- The IMAGE STYLE doesn't get its face color. HOT 9
- Custom panel actors completely overwrite the actors object. HOT 4
- MSDOS support, really? (Feature Request/Fix, or should rename the --target) HOT 6
- Words fail to stay local in blocks evaluated with loop block evaluator: repeat HOT 3
- Words fail to stay local in blocks evaluated with loop block evaluators: foreach HOT 3
- value? fails HOT 8
- WISH: DRAW command PEN should have option DOTTED HOT 3
- Point to point conversions are buggy HOT 1
- VID area blocked and slow on big text HOT 8
- New fix for area does not work with WRAP HOT 8
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from red.