View previous topic :: View next topic |
Author |
Message |
Brent Site Admin
Joined: 01 Jul 2005 Posts: 800
|
Posted: Mar 10th, 2012, 7:10pm Post subject: Experiment - Multiple uses for the apostrophe |
|
|
This is yet another thought experiment to gauge potential users' reactions to VF's syntax.
The apostrophe (') will likely be overloaded for numerous purposes. Mostly it will be used to comment code.
Code: | ' This is a comment.
pi = 3.14 ' This is another comment. |
Additionally, VF will introduce block comments.
Code: | '<
This is a simple block comment.
It can span multiple lines.
>' |
This would also allow comments within lines of code.
Code: | x = foo(bar, '<default>', baz) |
Like C/C++, block comments may not be nestable. To make nestable comments would require explicit labeling.
Code: | '<foo>
This is the first level of comments.
'<bar>
This is the second level.
You can continue nesting as long as each block has a unique label.
'</bar>
Now we're back in the first level.
'</foo> |
Now for something completely different.
I think it's a bit ugly how most BASICs require a function call to get the ASCII or Unicode number of a character. In LB you use ASC("A") to get 65. C/C++ allows one to write 'A' and it gets treated like 65 on most modern computers. VF should allow you to write ('A') and get the same result.
Code: | ' Go through the alphabet
for letter = ('A') to ('Z')
' Do something.
end for |
_________________ Brent |
|
Back to top |
|
|
STPendl Full Member
Joined: 20 Aug 2007 Posts: 161 Location: Austria
|
Posted: Mar 10th, 2012, 9:55pm Post subject: Re: Experiment - Multiple uses for the apostrophe |
|
|
I like the block comment and the ability to use the ASCII value similar to C.
Haven't made my mind up about nested comments yet. _________________ Stefan
Any code I post can be freely used, just give credit.
Last edited by STPendl on Mar 11th, 2012, 9:49am; edited 1 time in total |
|
Back to top |
|
|
Alyce Full Member
Joined: 04 Jul 2005 Posts: 91
|
Posted: Mar 10th, 2012, 11:18pm Post subject: Re: Experiment - Multiple uses for the apostrophe |
|
|
Who are the potential users? Are they to be novice programmers, somewhat skilled, or experienced programmers? _________________ - Alyce |
|
Back to top |
|
|
Brent Site Admin
Joined: 01 Jul 2005 Posts: 800
|
Posted: Mar 10th, 2012, 11:45pm Post subject: Re: Experiment - Multiple uses for the apostrophe |
|
|
Alyce, like most content on this site, VF's expected skill level is intermediate to advanced. Do you have any particular concerns? _________________ Brent |
|
Back to top |
|
|
Brent Site Admin
Joined: 01 Jul 2005 Posts: 800
|
Posted: Mar 10th, 2012, 11:55pm Post subject: Re: Experiment - Multiple uses for the apostrophe |
|
|
STPendl wrote: | Haven't made my mind up about nested comments yet. |
One purpose would be to comment out chunks of code that contain block comments because simple blocks aren't nestable. Of course, all block comments could be made nestable, but then the lexer has to keep track of these.
Another purpose could be to parse these comments as XML, which might allow an external tool to auto-generate documentation. _________________ Brent |
|
Back to top |
|
|
Alyce Full Member
Joined: 04 Jul 2005 Posts: 91
|
Posted: Mar 11th, 2012, 12:49am Post subject: Re: Experiment - Multiple uses for the apostrophe |
|
|
Brent wrote: | Alyce, like most content on this site, VF's expected skill level is intermediate to advanced. Do you have any particular concerns? |
Not at all. My response would be different if you were aiming at novice programmers. I assumed you were targeting more experienced folks, but I wanted to be sure.
Nested levels of comments seems overkill, even for experienced coders, but I could see where it might be useful. _________________ - Alyce |
|
Back to top |
|
|
JosephE Junior Member
Joined: 01 Nov 2007 Posts: 21
|
Posted: May 15th, 2012, 3:03am Post subject: Re: Experiment - Multiple uses for the apostrophe |
|
|
I would really like to see something similar to documentation comments similar to VB.NET's, minus the XML (which seems like over-kill to me). This would allow the IDEs to utilize intelligent code-completion on user created code libraries.
Code: |
''' This is a documentation comment describing this boring function that
''' performs a rather redundant algorithm. Since this comment appears right
''' before the declaration, a good IDE should be able to use this in auto
''' complete
function DoSomething(param) ' or however functions are declared in VF
param = param
return param
end function
|
|
|
Back to top |
|
|
|