Sign in Join

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

Mailing lists / fpc-pascal / 2012-11

Questions About Porting Java and Extended Class Syntax Features

6 messages · 4 people · –

Reply by email Subscribe to this list Your subscription

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

bsquared

Hello,

I am looking into porting Java to Free Pascal. I have some confusion about how to port certain types of Java Lang Features.

What is the best way to port 'private static final' member? I was thinking the extended class syntax would cover this, but I dont it will work for a scenario like this:

  private static final ObjectMapper mapper = new ObjectMapper();

or

  private static final  Set<String> = STATIC_SET;
  static {
  STATIC_SET = new HashSet<String>;
  STATIC_SET.Add("A Value");
  ...
  }

Any insight you may have is appreciated.

Thank you.

Regards, Brian

Reply by email

JC Chu

If you need to initialize a [STRICT] PRIVATE CLASS VAR you need to do this in a CLASS CONSTRUCTOR (similarly finalizations will need a CLASS DESTRUCTOR). You can expose it thru a read-only CLASS PROPERTY, but there is no way to make it a real constant (as long as you can access the variable itself, you can modify it).

Best regards, JC Chu *From:* bsquared *Sent:* ‎November‎ ‎7‎, ‎2012 ‎9‎:‎37 *To:* *Subject:* [fpc-pascal] Questions About Porting Java and Extended Class Syntax Features Hello, I am looking into porting Java to Free Pascal. I have some confusion about how to port certain types of Java Lang Features. What is the best way to port 'private static final' member? I was thinking the extended class syntax would cover this, but I dont it will work for a scenario like this: private static final ObjectMapper mapper = new ObjectMapper(); or private static final Set<String> = STATIC_SET; static { STATIC_SET = new HashSet<String>; STATIC_SET.Add("A Value"); ... } Any insight you may have is appreciated. Thank you. -- Regards, Brian

Reply by email

leledumbo
to bsquared: I am looking into porting Java to Free Pascal. I have some confusion about how to port…
What is the best way to port 'private static final' member?

private class var (assuming you want to declare a variable).

private static final Set<String> = STATIC_SET;
  static {
  STATIC_SET = new HashSet<String>;
  STATIC_SET.Add("A Value");
  ...
  }

Static initialization block has no equivalent in Pascal, but since unit have initialization section, you can initialize it there.

Reply by email

bsquared
to leledumbo
leledumbo wrote 23 lines
> What is the best way to port 'private static final' member? private class var (assuming you want to declare a variable). > private static final Set<String> = STATIC_SET; static { STATIC_SET = new HashSet<String>; STATIC_SET.Add("A Value"); ... } Static initialization block has no equivalent in Pascal, but since unit have initialization section, you can initialize it there. -- View this message in context: http://free-pascal-general.1045716.n5.nabble.com/Questions-About-Porting-Java-and-Extended-Class-Syntax-Features-tp5711825p5711827.html Sent from the Free Pascal - General mailing list . _______________________________________________ fpc-pascal maillist - http://lists.freepascal.org/mailman/listinfo/fpc-pascal

@leledumbo
Thank you. It has been a while. I unremembered the initialization and finalization sections.

@JC Chu
Thank you I was unaware of the 'class constructor' and 'class destructor'.

As an aside, I would like to note that after a couple of years away I still see the same contributers in this list, and it is excellent to find that support and commitment.

Regards, Brian

Reply by email

Sven Barth
to bsquared
"bsquared" wrote
As an aside, I would like to note that after a couple of years away I

still see the same contributers in this list, and it is excellent to find that support and commitment.

After all we have to keep the Pascal community living (or spoken in a recent context: defend the small FPC kingdom against the bigger ones ;) ).

Regards,
Sven

Reply by email

leledumbo
to bsquared: @leledumbo Thank you. It has been a while. I unremembered the initialization and…
As an aside, I would like to note that after a couple of years away I still

see the same contributers in this list, and it is excellent to find that support and commitment.

It's not our time yet to retire and hand over the kingdom to the little princes (single 's') out there, as they still need to learn a lot before replacing us so that they can maintain the kingdom as we do now XD

Reply by email