Comments (4)
It's worth considering, but it's a little like adding macros- the simple implementation is easy, but this quickly turns into a more elaborate feature. Single addition/subtraction/multiplication expressions will be useful for certain situations, but you really want fully nestable expressions. This might require rewriting Octo's token-at-a-time parsing strategy.
One relatively simple idea I had was to use {}
to permit embedding arbitrary javascript expressions, computed at compile time. With a little magic you could inject Octo constants (and labels) into the JS scope and the results would be fairly clean to use and very flexible. You'd even be able to compute complex lookup tables this way, right in your Octo source code. There are downsides to this idea, though- not only would it permanently tie the Octo language to Javascript (there has been a bit of tinkering done with making an Octo-compatible assembler in C#, for example), but it would also mean that compiling Octo programs becomes a potential security risk with arbitrary code execution on the client (in the browser, fairly sandboxed, but not if you use the Node CLI frontend).
I am not hard-set against having constant expression evaluation in Octo, but I want to make it clear that doing it right will be a big effort, both in design and implementation, and any solution must be backwards-compatible with the existing corpus of Octo programs.
from octo.
I was thinking about supporting very simple expressions, maybe even without braces for now. This is perfectly compatible with current language. This could be very handy and many assemblers (masm/tasm for sure, even z80's ZEUS) supported it. :)
Frankly, I think that inlining js code is not so good idea at all.
from octo.
I just added a new preprocessor command, :calc
, which I believe addresses this issue. See 5b8506e for details and documentation. :calc
permits you to compute a constant based on existing constants or literals, so the above could be written as something like:
:const step 12
:const x 10
:calc y { x + step }
va := x
vb := y
It's a bit more verbose than allowing expressions directly within arguments to Octo instructions, but allows you to express relationships between constants at compile time.
from octo.
Yes, this is definitely cleaner solution. Thanks a lot
from octo.
Related Issues (20)
- Support mouse in addition to touch controls HOT 2
- Document another audio playback behavior into XO-ChipSpecification
- Broken link at end of Sorting.md
- Octo UI buttons are invisible on a white background
- Slight bug with the decompiler in the Octo IDE regarding the pitch opcode
- Plane 3 Bug (Only enables the first bit plane) HOT 2
- Gamepad visible in browser HOT 4
- XO-Chip manual section has a broken link to the XO-Chip spec in repo view
- Possible Instruction Prefix Support for XO-CHIP HOT 4
- Add support for viewport scaling to exported HTML HOT 1
- Yet Another Proposal: Stereo Audio with Multi-Voice Support (Sweet and Simple Design)
- Solving the difficulty of writing program's code beyond 4k with banking HOT 1
- No Audio Output Issue on HTML Output HOT 2
- collision enumeration quirk HOT 3
- scroll-up can scroll in pixels which aren't blank HOT 4
- Octo reads .sc8/.xo8 files as plaintext, should read them as binaries HOT 1
- Constants in data interpreted as call HOT 2
- Expected order of operations for vf HOT 2
- Maximum ROM Size for VIP too small HOT 4
- Step function can proceed past Fx0A without input HOT 2
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 octo.