Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / pas2js / 2020-02

pas2js doesn’t support -Sj

8 messages · 4 people ·

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

Mr Bee

Hi,
Just update my pas2js to v1.5 (trunk). It seems pas2js doesn’t support -Sj option (writeable constant). Would you please support it? I think writeable constant is a design mistake of Pascal language by Borland that we have to deal forever. Personally, I always disable it, since I knew it could be disabled. FPC should disable it by default too, at least on ObjFPC mode. A constant should never be writeable, ever. Thank you.
Regards,
–Mr Bee
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freepascal.org/pipermail/pas2js/attachments/20200201/25d31eda/attachment.html>

Reply by email

Michael Van Canneyt
to Mr Bee
Mr Bee wrote
Hi, Just update my pas2js to v1.5 (trunk). It seems pas2js doesn’t support -Sj option (writeable constant). Would you please support it? I think writeable constant is a design mistake of Pascal language by Borland that we have to deal forever. Personally, I always disable it, since I knew it could be disabled. FPC should disable it by default too, at least on ObjFPC mode. A constant should never be writeable, ever.

I don't understand what you want ?
Do you want consts to be writable or not ? You ask for a switch but at the same time advocate against writable const ?

That said:

I really don't think we should support this. Not any more.

If 20 years after the demise of Turbo Pascal we cannot expect people to change a couple of consts into a var, then all hope for humanity (well, at least the pascal programming community) is simply lost.

FPC was created when TP still existed. It made sense to allow writable const for easy porting. Same for Delphi. But IMHO not in a new tool 25 years after the facts.

I would not stop patches that implement this, but I consider this very low priority indeed.

Michael.

Reply by email

Mattias Gaertner
to Michael Van Canneyt
Show quoted text 14 lines
On Sat, 1 Feb 2020, Mr Bee via Pas2js wrote: > Hi, > Just update my pas2js to v1.5 (trunk). It seems pas2js doesn’t > support -Sj option (writeable constant). Would you please support > it? I think writeable constant is a design mistake of Pascal > language by Borland that we have to deal forever. Personally, I > always disable it, since I knew it could be disabled. FPC should > disable it by default too, at least on ObjFPC mode. A constant > should never be writeable, ever. I don't understand what you want ? Do you want consts to be writable or not ? You ask for a switch but at the same time advocate against writable const ?

-Sj was added in fpc 3.3.1 (or was it 3.1?) and enables writeables const (default).
Mr Bee wants to disable it (-Sj-) to get read only const.

pas2js supports the directive {$writeableconst off}. It was lacking the -Sj flag.

I added it now.

Mattias

Reply by email

Sven Barth
to Michael Van Canneyt: I don't understand what you want ? Do you want consts to be writable or not ? You ask for…
Michael Van Canneyt wrote 7 lines
If 20 years after the demise of Turbo Pascal we cannot expect people to change a couple of consts into a var, then all hope for humanity (well, at least the pascal programming community) is simply lost. FPC was created when TP still existed. It made sense to allow writable const for easy porting. Same for Delphi. But IMHO not in a new tool 25 years after the facts.

The main use of writable consts that you can only cover with OOP otherwise is static, scoped variables. I personally agree that global constants should be declared as readonly, but for local ones there might be a use for it even if you or I don't necessarily consider it a good one.

Regards,
Sven

Reply by email

Sven Barth
to Mr Bee: Just update my pas2js to v1.5 (trunk). It seems pas2js doesn’t support -Sj option…
Mr Bee wrote 9 lines
Hi, Just update my pas2js to v1.5 (trunk). It seems pas2js doesn’t support -Sj option (writeable constant). Would you please support it? I think writeable constant is a design mistake of Pascal language by Borland that we have to deal forever. Personally, I always disable it, since I knew it could be disabled. FPC should disable it by default too, at least on ObjFPC mode. A constant should never be writeable, ever.

FPC values backwards compatibility. As such a mode won't be changed in such a way that existing code suddenly no longer compiles without good reason.

Also as I wrote to Michael, the use of writable consts is as static, scoped variables if one doesn't want to resort to OOP (and for simple functions that might indeed be overkill).

Regards,
Sven
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freepascal.org/pipermail/pas2js/attachments/20200201/1dd4fe33/attachment.html>

Reply by email

Michael Van Canneyt
to Sven Barth: The main use of writable consts that you can only cover with OOP otherwise is static,…
Sven Barth wrote 13 lines
Am 01.02.2020 um 09:33 schrieb Michael Van Canneyt: > If 20 years after the demise of Turbo Pascal we cannot expect people > to change a couple of consts into a var, then all hope for humanity > (well, at least the pascal programming community) is simply lost. > > FPC was created when TP still existed. It made sense to allow writable > const for easy porting. Same for Delphi. But IMHO not in a new tool 25 > years after the facts. The main use of writable consts that you can only cover with OOP otherwise is static, scoped variables. I personally agree that global constants should be declared as readonly, but for local ones there might be a use for it even if you or I don't necessarily consider it a good one.

Indeed, I don't see the point of static scoped variables. But if you need those, then I'd rather see

var a : integer; static;

or something similar, than

const
   a : Integer= 0;

Const should be exactly that, a const. My guess is that the original "writable const" was simply a bug declared a feature.

Michael.

Reply by email

Mr Bee
to Mattias Gaertner: On Sat, 1 Feb 2020 09:33:22 +0100 (CET) -Sj was added in fpc 3.3.1 (or was it 3.1?) and…

Correct. I’m now using FPC v3.2 (fixes).
Thank you for making my intention much clearer. Forgive me for I’m not a native English speaker. Sometimes I compose my intention unclear enough to people who fluent in English though my writing is grammarly correct. Thank you again for adding -Sj flag so I could put it in config or command line options. –Mr Bee

Pada Sabtu, 1 Februari 2020 17.45.16 WIB, Mattias Gaertner via Pas2js menulis:

Show quoted text 14 lines
On Sat, 1 Feb 2020, Mr Bee via Pas2js wrote: > Hi, > Just update my pas2js to v1.5 (trunk). It seems pas2js doesn’t > support -Sj option (writeable constant). Would you please support > it? I think writeable constant is a design mistake of Pascal > language by Borland that we have to deal forever. Personally, I > always disable it, since I knew it could be disabled. FPC should > disable it by default too, at least on ObjFPC mode. A constant > should never be writeable, ever.  I don't understand what you want ? Do you want consts to be writable or not ? You ask for a switch but at the same time advocate against writable const ?

-Sj was added in fpc 3.3.1 (or was it 3.1?) and enables writeables const (default).
Mr Bee wants to disable it (-Sj-) to get read only const.

pas2js supports the directive {$writeableconst off}. It was lacking the -Sj flag.

I added it now.

Mattias

Reply by email

Mr Bee
to Michael Van Canneyt: Indeed, I don't see the point of static scoped variables. But if you need those, then I'd…

Writable constant indeed doesn’t make any sense, either in semantic or scoped variable. That’s why I prefer to disable it by default. Even Delphi had it disabled since Delphi 3, if my memory serves me right. However, this topic had been discussed over and over since a decade ago in FPC list but nothing changes. FPC still enables it by default both in Delphi and FPC mode.

–Mr Bee

Pada Sabtu, 1 Februari 2020 19.30.38 WIB, Michael Van Canneyt menulis:

Sven Barth wrote 13 lines
Am 01.02.2020 um 09:33 schrieb Michael Van Canneyt: > If 20 years after the demise of Turbo Pascal we cannot expect people > to change a couple of consts into a var, then all hope for humanity > (well, at least the pascal programming community) is simply lost. > > FPC was created when TP still existed. It made sense to allow writable > const for easy porting. Same for Delphi. But IMHO not in a new tool 25 > years after the facts. The main use of writable consts that you can only cover with OOP otherwise is static, scoped variables. I personally agree that global constants should be declared as readonly, but for local ones there might be a use for it even if you or I don't necessarily consider it a good one.

Indeed, I don't see the point of static scoped variables. But if you need those, then I'd rather see

var a : integer; static;

or something similar, than

const
  a : Integer= 0;

Const should be exactly that, a const. My guess is that the original "writable const" was simply a bug declared a feature.

Michael.

Reply by email