Comments (9)
Hey @cjpbirkbeck, I think it is a good idea. I have been using #
as an alias of count
, but I will happily give it away in order to have comments. The patch is simple:
diff --git a/clac.c b/clac.c
index 7d08fa5..3fce9d2 100644
--- a/clac.c
+++ b/clac.c
@@ -260,6 +260,10 @@ static void load(sds filename) {
for (i = 0; i < linecount; i++) {
lines[i] = sdstrim(lines[i], " \t\r\n");
+ if (lines[i][0] == '#') {
+ continue;
+ }
+
if (parse(lines[i]) != 0) {
sdsfreesplitres(lines, linecount);
Before making a definitive decision, I would like to have the opinion of @waltertross, another big user of clac.
from clac.
hi, it would work, but it's a bit of a pity if the #
cannot be used as a word any more. I thought of //
, but that can also be useful as a word for integer division (if you come from Python). I don't know, maybe '
or "
. Also /*
closed by */
would be nice, but spreading this over lines, or handling more than one on a line, would make the code definitely more complicated. An idea which would break lots of rules would be a /*
at start of line, NOT CLOSED. But that's too revolutionary, probably ;-) A very conservative idea, OTOH, would be to NOT allow line comments, and to allow a comment string (enclosed in quotes) to follow the word definition string. This would stay associated with the word, and would be printed out by the words
command.
from clac.
Ah, but in search for a solution I found that the #
at start of line is perfectly viable, because already now the word being defined can be enclosed in double quotes, so that your alias for count
, @soveran, can be defined as "#"
! So... green light!
from clac.
Woops, I left my last comment as wtross-eg. It's still me, but as an EG employee...
from clac.
Wow, that's a great finding! I tested it and having comments looks like a good improvement. I'll document it and push the changes.
from clac.
Added in this commit: ba208c0
@waltertross @cjpbirkbeck If you are OK with the implementation and the comment, I will release a new version.
from clac.
Maybe for completeness you might want to add something similar to the following, somewhere:
Note that to define the word # you have to use "#"
in order for the definition not to be interpreted as a comment
If you don't write something like this anywhere, most users will be unable to define the #
word.
from clac.
Maybe for completeness you might want to add something similar to the following, somewhere:
Note that to define the word # you have to use "#"
in order for the definition not to be interpreted as a commentIf you don't write something like this anywhere, most users will be unable to define the
#
word.
I agree and I would suggest that an extra paragraph is added to the man page documenting how comments are written and how to escape #
. Again, I'm not sure if I have written the troff syntax correctly, but I would suggest something like the following:
.
.Ss Comments
.
Any lines that begin with
.Sy #
are considered to be a comment, and are ignored. There are no inline comments, and any
.Sy #
characters that is not the first character is interpreted literally. To assign
.Sy #
as an operation, use
.Sy "#"
. So, for example:
.Pp
.Dl # This is a comment.
.Dl "#" "count"
.Pp
This assigns
.Sy #
to the operation
.Sy count.
.
from clac.
Excellent, I added a paragraph to both the README and the man page: beae8c4
Can you check it?
from clac.
Related Issues (16)
- Great Code HOT 4
- Suggestion: Sci-Calc HOT 10
- Current stable version? HOT 1
- Suggestion: Factorial function HOT 4
- 0.3.2 build failure on macOS HOT 1
- It's even better HOT 1
- Suggestion: rename to clsc HOT 1
- Add more functions in `math.h` HOT 8
- Clarification in the docs HOT 2
- Segmentation fault for circular definition in words HOT 2
- Suggestion: reduce need for spaces HOT 1
- Ubuntu has issues with the placement of the -lm flag HOT 1
- postfix after number should work and not be "ignored" HOT 3
- Add a tag or create release HOT 16
- Stack operator to roll top three values HOT 4
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 clac.