Forum > Windows

$MINSTACKSIZE unexpected behavior without warning

(1/5) > >>

440bx:
Hello,

including a simple expression in $MINSTACKSIZE such as {$MINSTACKSIZE 7 * 1024 * 1024} causes its value to be set to 7 instead of 7,000,000 without a warning, note or any indication that the value used is nowhere near the value specified.

The documentation does not state whether or not an expression is valid but, when using one, the compiler doesn't complain giving the impression that using an expression is valid when it really is not.

Comments welcome.

MarkMLl:
But is this really unexpected? $endif etc. ignore anything after the first space so it's reasonable to assume that that's the default behaviour: are there any pragmata where an expression, particularly one not parenthesised, is evaluated?

MarkMLl

440bx:

--- Quote from: MarkMLl on February 17, 2024, 12:29:19 pm ---But is this really unexpected?

--- End quote ---
What I consider unexpected is the lack of any warning or note about the compiler ignoring the remainder of the expression.  Whatever routine is parsing that directive must be looking for the closing brace "}" therefore it is aware of all the characters in between yet says nothing about ignoring them.   That's just not the way a normal parser behaves.

MarkMLl:
But pragamata and comments aren't parsed, they're generally handled by the lexer (which is why a conditionally-compiled fragment doesn't have to be valid Pascal, and why nested comments are an issue). You don't expect a warning from either

{$endif WINDOWS } <-- "Appended string WINDOWS ignored"

or

{$endif } <-- "Missing closing identifier"

This might be something which could benefit from being explicitly mentioned in the documentation: when doing this stuff myself I've sometimes put a box at the top of a documentation section with checkboxes for "Parameter invalid", "numeric parameter expected", "expression parameter expected" and so on.

But I would say that there's so many places where things aren't spelled out explicitly that you really would be opening the floodgates...

MarkMLl

440bx:

--- Quote from: MarkMLl on February 17, 2024, 12:54:06 pm ---This might be something which could benefit from being explicitly mentioned in the documentation:

--- End quote ---
I think that is something that _must_ be mentioned in the documentation.  Ignoring characters in what is not documented as a comment area is _not_ expected behavior in a compiler. 

You brought up a good example in {$ENDIF}, here how it's documented:
--- Quote ---The {$ENDIF} directive ends the conditional compilation initiated by the last {$IFxxx} directive. Any text after the ENDIF keyword but before the closing brace is ignored:

{$ENDIF some ignored text}
is the same as

{$ENDIF}
--- End quote ---
any implicit "comment area" should most definitely be documented.  A programmer should never have to guess whether what he/she typed is honored by the compiler.  That should always be known without any doubts.

Navigation

[0] Message Index

[#] Next page

Go to full version