Recent

Author Topic: unicode chars in identifiers names  (Read 4584 times)

mrspock1

  • New Member
  • *
  • Posts: 29
unicode chars in identifiers names
« on: August 02, 2018, 09:25:21 pm »
Is it possible to use national chars in identifiers (like variable names) in a similar way to Delphi?
« Last Edit: August 02, 2018, 09:28:41 pm by mrspock1 »

Thaddy

  • Hero Member
  • *****
  • Posts: 14373
  • Sensorship about opinions does not belong here.
Re: unicode chars in identifiers names
« Reply #1 on: August 02, 2018, 09:42:40 pm »
Delphi can't do that..... (AFAIK) Delphi adheres strictly to Pascal naming conventions, just like FreePascal does.
The allowed range is defined as 'A'..'Z', 'a'..'z', '_','0'..'9' and in both Delphi and Freepascal '&', which is not part of the language definition but an escape to resolve naming conflicts.
I would be amused to see an example, though.... :D
Object Pascal programmers should get rid of their "component fetish" especially with the non-visuals.

mrspock1

  • New Member
  • *
  • Posts: 29
Re: unicode chars in identifiers names
« Reply #2 on: August 02, 2018, 09:47:03 pm »
You will be very amused to find this has been true for several years. I used national chars for variable names in Delphi Tokyo, which helped me a lot. Now I will need a hammer to replace all national chars in my code back to English chars.

Thaddy

  • Hero Member
  • *****
  • Posts: 14373
  • Sensorship about opinions does not belong here.
Re: unicode chars in identifiers names
« Reply #3 on: August 02, 2018, 10:01:28 pm »
Show example: I just tested Delphi 10.2.
Show example! A compilable - in Delphi -  O:-) example.....
« Last Edit: August 02, 2018, 10:12:09 pm by Thaddy »
Object Pascal programmers should get rid of their "component fetish" especially with the non-visuals.

mrspock1

  • New Member
  • *
  • Posts: 29
Re: unicode chars in identifiers names
« Reply #4 on: August 02, 2018, 10:09:12 pm »
Here it is.

One of my graph searching projects with national chars in identifiers names ąśżęćźółń

Thaddy

  • Hero Member
  • *****
  • Posts: 14373
  • Sensorship about opinions does not belong here.
Re: unicode chars in identifiers names
« Reply #5 on: August 02, 2018, 10:23:02 pm »
Here it is.

One of my graph searching projects with national chars in identifiers names ąśżęćźółń
Indeed. That is a bug in Delphi. It should never support that. It used to NOT support it.
This is food for a new discussion thread. Btw, with Macro's you can partially get something like that.
Object Pascal programmers should get rid of their "component fetish" especially with the non-visuals.

mrspock1

  • New Member
  • *
  • Posts: 29
Re: unicode chars in identifiers names
« Reply #6 on: August 02, 2018, 10:31:53 pm »
I think it was done on purpose to help to create readable code (the feature is also in php).

I was going to move my code from Delphi to Lazarus tomorrow, but now I will wait for changes in Lazarus to be done about that.

wp

  • Hero Member
  • *****
  • Posts: 11916
Re: unicode chars in identifiers names
« Reply #7 on: August 02, 2018, 10:54:11 pm »
but now I will wait for changes in Lazarus to be done about that.
You will have to wait long for that. And I hope that FPC will never have this feature...

Right-click on your localized identifiers, select "Refactoring" > "Rename identifier". Enter a good English name for it, select the scope needed and press "Rename all References". If you do it correctly this identifier will be renamed at all occurances. Repeat with the others. The reason why I recommend English identifiers: You are here in an international forum, and you are presenting obfuscated code to the people who are willing to help you. What if a non-native programmer enters your team? How do you imagine that anybody can help you if he/she does not understand the words in the code?
« Last Edit: August 02, 2018, 10:56:22 pm by wp »

ASerge

  • Hero Member
  • *****
  • Posts: 2242
Re: unicode chars in identifiers names
« Reply #8 on: August 02, 2018, 11:18:49 pm »
...I recommend English identifiers...
+1
Use English and in the code comments.

Thaddy

  • Hero Member
  • *****
  • Posts: 14373
  • Sensorship about opinions does not belong here.
Re: unicode chars in identifiers names
« Reply #9 on: August 03, 2018, 05:43:46 am »
Single biggest mistake as a "feature". It looks completely silly. I am installing wingdings as my favored editor font in D10.2. Somebody wasn't paying attention at Embarcadero.
Object Pascal programmers should get rid of their "component fetish" especially with the non-visuals.

mrspock1

  • New Member
  • *
  • Posts: 29
Re: unicode chars in identifiers names
« Reply #10 on: August 03, 2018, 06:54:56 am »
As to fonts, there should be a total change like it is done in pdf. End user may not have installed fonts used by app. Now there is a method to create fonts on running, but it is awkward. Fonts should be attached to executable automatically.

taazz

  • Hero Member
  • *****
  • Posts: 5368
Re: unicode chars in identifiers names
« Reply #11 on: August 03, 2018, 08:07:49 am »
so because you do not intent to evolve everything must stay static. Not implementing it is a choice you entitled to, demonizing it is an act you have no right to take. The choice to be international or not, is not for us to decide you either support it  or not and if you do not you have no right to complain.
Good judgement is the result of experience … Experience is the result of bad judgement.

OS : Windows 7 64 bit
Laz: Lazarus 1.4.4 FPC 2.6.4 i386-win32-win32/win64

marcov

  • Administrator
  • Hero Member
  • *
  • Posts: 11452
  • FPC developer.
Re: unicode chars in identifiers names
« Reply #12 on: August 03, 2018, 09:35:26 am »
Afaik this was a D2009 feature.

Thaddy

  • Hero Member
  • *****
  • Posts: 14373
  • Sensorship about opinions does not belong here.
Re: unicode chars in identifiers names
« Reply #13 on: August 03, 2018, 10:38:52 am »
Afaik this was a D2009 feature.
Well, I have to admit it has been under the radar to me all the time. It's plain silly and it is not surprising a question like this turns up after "only" 10 years.....
I can read a bit of Polish but to anyone non-Polish or not at least a bit capable of the language this must be a nightmare  :o :( :( :( %)
To Paraphrase Asterix and the Helvetians they should drown the culprit engineer in fondue. (Of course a reference to the Swiss background of Pascal, which country with all its languages has its fair share of "estranged" characters).
I think I am really going to demo all my QC's to Embarcadero in Wingdings or better one of the Emoji fonts..<WTF?>

Is this supposed to be the "famed" backwards compatibility or retarded?
« Last Edit: August 03, 2018, 10:56:10 am by Thaddy »
Object Pascal programmers should get rid of their "component fetish" especially with the non-visuals.

Pascal

  • Hero Member
  • *****
  • Posts: 932
Re: unicode chars in identifiers names
« Reply #14 on: August 03, 2018, 11:17:09 am »
Quote from: Paweł Głowacki - Expert Delphi - Page 62
In Object Pascal source code, you can use any Unicode characters for identifiers, but it
makes a lot of sense to stick to just ASCII characters and consistently use just the English
language in your code. Different Object Pascal language elements are in English, and it is
easier to work with other programmers who might use other languages as their mother
tongue.

So smileys too!
« Last Edit: August 03, 2018, 11:18:47 am by Pascal »
laz trunk x64 - fpc trunk i386 (cross x64) - Windows 10 Pro x64 (21H2)

 

TinyPortal © 2005-2018