[fpc-pascal] Bls: Bls: Quick Modern Object Pascal Introduction, for Programmers

Mr Bee pak.lebah at yahoo.com
Tue Jun 21 08:48:05 CEST 2016


> I definitely *do not want* to explain to any new programmer what a "writeable constant" is... This concept should remain buried :) Exactly! I also don't understand why the {$MODE OBJFPC} uses the {$J+} as the default. :)

–Mr Bee
 

    Pada Selasa, 21 Juni 2016 12:47, Michalis Kamburelis <michalis.kambi at gmail.com> menulis:
 

 2016-06-20 5:31 GMT+02:00 Mr Bee <pak.lebah at yahoo.com>:
[...]
> I have a little suggestion though. I prefer to use {$J-} directive in my
> Pascal program. I think it encourages good programming practice in Pascal.
> The {$J-} means constant is a constant no matter how you declare it. To bad
> FPC is still using {$J+} as the default even in the {$MODE OBJFPC}, which
> means a constant becomes a variable once you include the data type
> eventhough it's declared within a 'const' block. CMIIW.
>

Ouch. For some reason, I thought that {$J-} is the default in {$mode
objfpc} since years, and we have left that mistake behind us. Quick
test showed me that I was mistaken. This makes a *lot* of my code less
safe that I assumed, as in many recent projects I didn't bother to
explicitly use {$J-}.

This is an excellent suggestion then, thank you. I updated the
document to encourage everywhere doing

  {$mode objfpc}{$H+}{$J-}

at the beginning.

I definitely *do not want* to explain to any new programmer what a
"writeable constant" is... This concept should remain buried:)

Regards,
Michalis


  
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freepascal.org/pipermail/fpc-pascal/attachments/20160621/3145f96e/attachment.html>


More information about the fpc-pascal mailing list