Sign in Join

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

Mailing lists / fpc-devel / 2010-04

default values and "$WRITEABLECONST OFF"

2 messages · 2 people · –

Reply by email Subscribe to this list Your subscription

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

Seth Grover

Why does disabling writing to typed constants (with $J or $WRITEABLECONST, see
http://www.freepascal.org/docs-html/prog/progsu40.html#x47-450001.1.40) make it so i cannot use those consts as default values for const parameters.

In other words, why does this produce an illegal expression when compiling?

===============================
program project1;
{$mode objfpc}{$H+}
{$WRITEABLECONST OFF}
type
  TestIntegerType = integer;
const
  TestIntegerZero : TestIntegerType = 0;
  TestIntegerOne : TestIntegerType = 1;
procedure AcceptTestInteger(const val : TestIntegerType = TestIntegerZero);
begin
end;
begin
  AcceptTestInteger();
end.
===============================

I don't see why that's al illegal expression. Is this a compiler bug? If not, can someone explain to me why this is not allowed?

Thanks,

-SG

This email is fiction. Any resemblance to actual events or persons living or dead is purely coincidental. Seth Grover sethdgrover[at]gmail[dot]com

Reply by email

Paul Ishenin
to Seth Grover
Seth Grover wrote
I don't see why that's al illegal expression. Is this a compiler bug? If not, can someone explain to me why this is not allowed?

It works the same in delphi.

Best regards,
Paul Ishenin.

Reply by email