There is very useful feature in Clarion language: if a code line begins with the ? character, it compiles in the debug mode only, i.e. if the debug(vid) pragma has value full or min.
I suggest to have another “magic” character in the first source line position to instruct the compiler to compile it if profile mode is turned on and omit if it is off. The profile mode can be turned on by the pragma debug(profile=>on) or define(profile=>on), default value is off.
At the moment it’s need to use OMIT/COMPILE blocks for profiling code as for usual conditionally compiled code. But as a rule profiling code consists of single calls to start/stop particular timer or counter. Usage of OMIT/COMPILE blocks makes the code less readable.
It would be useful to allow that new “magic” character in thee data section too to declare data used for profiling.
Specifies the compiler will invoke a procedure call at the beginning and end of compiling each procedure. This allows you to implement your own profiler. The prototypes for these procedures must be:
The EnterProc is called at the beginning of each procedure and LeaveProc at the end.
Is this to make it easier to include Unicode data types in an app so that Profile can be used to switch from Ansi to Unicode easily?
Col 1 # is a comment in languages like Python, Bash, Ruby, Perl, and R
Col 1 # is a preprocessor command in C/C++
Col 1 > is a preprocessor command in Fortran
Col 1 > is quoted block of text in text formats, markdown, or documentation files
Python is taught the most at Universities in the first year, and in CS courses switch to C/C++ in the second year.
If you are catering for new/future users I would probably go with #.
This is too crude mechanism in my opinion. If pragma define(profile) is on, the compiler generates calls to Profile:EnterProc on entry to all functions and routines and calls to Profile:LeaveProc on return. Usually it’s need to do measuring between some points in the source code.
Any character can be potentially used in any position in Forth
My preference is # because following code is legal
Could you use the same character? If debug is off then the profile pragma takes effect (or not)
That assumes that no one does debugging and profiling at the same time though.
I considered ? - lines beginning with ? Could be compilable if debug or profiling modes or both are on. The reason why ? character is not suitable for lines with profiling code is desire to allow such lines in the data section. The compiler allows identifiers beginning with ? character. It’s a side effect of considering controls’ equate labels as EQUATEs.
In part it was readability that I had in mind when I made the suggestion. By referencing the pragma define, it becomes self documenting what condition we’re omitting based on - which makes it readable.
readability and power/flexibility too, Instead of adding some special symbol that is only useful for the single case of profiling, I was suggesting something that could be used for a wide variety of situations.
Clarion source code and Clarion template code are different animals
It’s oossible to use any characters in embed points
The template language has the special construct %# expanding to a single sharp character
Really, the choice for the new “magic” character is very narrow because it must be a symbol which can’t be a lexeme itself and none valid lexeme can start with it. Plus such character must be confidently determinable being typed using wide range of fonts. Besides mentioned I see only tilda character as a candidate.