Comments (5)
You can comment out a block (with // comments) in VS Code using Ctrl-K-C, similar block commenting is available in other editors.
There's probably a good reason for not having /* and */ , I just cant remember what it is :)
from millfork.
The reasons for not having block comments are having to decide:
- what to do with nested comments
- what to do when an end-of-comment token occurs inside a (potentially malformed) string literal
Both those issues are important when using block comments to comment out code, but can also occur in artificial one-line examples:
/* xxx /* xxx */ is this commented out or not? */
/* " */ is this commented out or not? " */
Right now, the closest Millfork has to block comments is the preprocessor; usually, you can wrap a piece of text in
#if 0
...
#endif
This nests and doesn't break because of strings, however due to being a preprocessor feature, it does not allow for certain tricky techniques a native comment feature would.
I would love some feedback:
- would Millfork improve by having block comments?
- should block comments nest?
- should the end token stand on its own line, to prevent various parsing issues?
- should the start token?
- what should the syntax look like?
- should Millfork get a standard documentation comment syntax?
from millfork.
Like you say, the #if 0 ... #endif can be used instead of /* / when debugging, personally feel / */ is unnecessary.
Regarding standard documentation comment syntax, I already use /// in my code where I think I might want to use doxygen in the future.
from millfork.
I tried Ctrl-K-C but I think because I have the millfork cx16 installed it doesn't work anymore. Maybe something needs to define what the comment char for 'millfork' is for it?
#if 0 is probably fine for code blocking. The benefit I see for /* is a lot of things will see it and know that it is a comment and colour it as such, while preprocessor #if defs don't get coloured or understood by normal text editors or even complex ones like xcode.
/* xxx /* xxx / is this commented out or not? /
/ xxx / xxx */ - is the comment
is this commented out or not? */ - not commented
inside " comments are not dealt with, for example I would also expect
"this is normal // this is still not commented " to work.
Follow C/C++ rules as that is what most text editors will do.
It also allows for context.
#if is now a code level construct and used to allow conditional code/handle multiple platforms etc
/* this is not code and is a comment, and should be considered as such
For example compare the visual structure of these two
#if C64
#if 0
This will set the memory map to just IO
Also disables the CIA IRQ/NMI
#endif
lda #$35
sta $01
#endif
#if C128
#if 0
This will set the memory map to just IO Block 0 RAM
Zero Page will be 0:0000
Stack Page will be 0:1000
VIC block will be 0
Also disables the VIC IRQ
#endif
lda #$fe
sta $ff00
lda #0
sta $d01a
sta $d506
sta $d50A
sta $d508
sta $d507
lda #1
sta $d509
lda $d019
sta $d019
#endif
#if Mega65
#if 0
This will set the memory map to just IO with no higher ram mapped
Z register will be reset to 0
Base Page is set to 0
Also disables the CIA IRQ/NMI
#endif
[$a9,$00,$aa,$a8,$4b,$5c,$ea,$5b]
#endif
#if C64 || Mega65
lda #$7f
sta $dc0d
sta $dd0d
lda $dc0d
lda $dc0d
#endif
#if C64
/*
This will set the memory map to just IO
Also disables the CIA IRQ/NMI
*/
lda #$35
sta $01
#endif
#if C128
/*
This will set the memory map to just IO Block 0 RAM
Zero Page will be 0:0000
Stack Page will be 0:1000
VIC block will be 0
Also disables the VIC IRQ
*/
lda #$fe
sta $ff00
lda #0
sta $d01a
sta $d506
sta $d50A
sta $d508
sta $d507
lda #1
sta $d509
lda $d019
sta $d019
#endif
#if Mega65
/*
This will set the memory map to just IO with no higher ram mapped
Z register will be reset to 0
Base Page is set to 0
Also disables the CIA IRQ/NMI
*/
[$a9,$00,$aa,$a8,$4b,$5c,$ea,$5b]
#endif
#if C64 || Mega65
lda #$7f
sta $dc0d
sta $dd0d
lda $dc0d
lda $dc0d
#endif
from millfork.
I apologize for the delay in responding. As part of my LSP work in #81 I implemented multiline comments in an attempt to conform to the JSDoc style of creating docstrings. As @KarolS correctly mentions, my implementation suffers from the comment termination and string handling issue, though I'm not sure how problematic these actually are. In my opinion, the value brought along with multiline comments (though really just any kind of automated doccomments) outweighs the compile errors that may occur due to difficult to parse scenarios. I don't think that it is possible to successfully build with one of the above scenarios.
In any case, as long as errors are thrown, I think that should be sufficient for now. As we start adding more featureful LSP support (such as highlighting compile errors in editor), the improved iteration time should make any such errors largely a non-issue.
from millfork.
Related Issues (20)
- Structs can't have volitile members HOT 1
- Implement ++ and -- operators in the Millfork language HOT 4
- file array initiliser can't handle maths
- Address of sid_v1_sr in file c64_sid.mfk is incorrect HOT 1
- 65CE02 JSR incorrect Assmbly HOT 1
- possible to pass a function to a macro? or find the identifier for the current function? HOT 3
- Maths doesn't promote to destination type HOT 6
- compiler accepts 'array(type)' but not 'array (type)'
- switch_hirom in c64_easyflash.mfk should write to $DE00 not $DE01
- clear_carry return doesn't work ?
- for x : array strange behavior
- Unnamed Structure and Union Fields
- Other label format support? HOT 3
- Support identity table usage HOT 2
- Assigning struct word member from another struct word member HOT 1
- Compiler assuming C clear when it isn't?
- Hello World example from documentation doesn't work HOT 1
- IX index is broken in the Z80 assembler.
- Strange invalid 16-bit optimization HOT 1
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 millfork.