Recent

Author Topic: I do not like ^  (Read 12944 times)

Fred vS

  • Hero Member
  • *****
  • Posts: 1675
    • miXimum is the DJ's best friend
I do not like ^
« on: November 17, 2012, 02:33:07 am »
It is a message for the High Authorities of the Pascal Academy.

I have a great respect for your language, but would it not time to take it completely ? Be brave and waive these legacies competitors.

Please, forget:
^variable
pointer^
@variable
(All are terrorizing our children)
 
and adopt:
DeRefPtr(variable)
RefPtr(pointer)
PtrtoVal(variable)
(Who are much more "Pascally").

Here example of "mixed" Official Pascal code (given by Mr Blaazen)

Code: [Select]
VAR W : Word;
    P : ^Word;

BEGIN
   W:=10;
   P:=@W;
   WriteLn(P^);
   W:=30;
   WriteLn(P^);
   P^:=80;
   WriteLn(W);
END.


and here the same code in "real" Pascal mood :

DeRefPtr(var) ----> ^var;
RefPtr(ptr) ----> ptr^ ;
PtrtoVal(var) ---->  @var ;

Code: [Select]
VAR W : Word;
    P : DeRefPtr(Word);

BEGIN
   W:=10;
   P:=PtrtoVal(W);
   WriteLn(RefPtr(P));
   W:=30;
   WriteLn(RefPtr(P));
 RefPtr(P):=80;
   WriteLn(W);
END.


Your obedient servant.

Fred vS
« Last Edit: June 26, 2017, 01:58:02 pm by Fred vS »
I use Lazarus 1.8.0 32/64 and FPC 3.0.3 32/64 on Linux Mint Mate 17 32/64, Windows 10, Windows 7 32/64, Windows XP 32,  FreeBSD 64 and Mac OS X Snow Leopard 32.
Widgetset: fpGUI, MSEgui, Win32, GTK2, Qt, Carbon.

https://github.com/fredvs

Leledumbo

  • Hero Member
  • *****
  • Posts: 8112
  • Programming + Glam Metal + Tae Kwon Do = Me
Re: I do not like ^
« Reply #1 on: November 17, 2012, 04:04:38 am »
Read this, Niklaus Wirth never invented Pascal with caret as the pointer dereference operator, it's our current keyboard that doesn't have the required symbol. And for you, symbolphobians, please stop doing something silly regarding the symbol. You have triangles everywhere: boomerang, underwear, arrows, etc. all have nothing to do with terrorism.

taazz

  • Hero Member
  • *****
  • Posts: 5363
Re: I do not like ^
« Reply #2 on: November 17, 2012, 04:29:33 am »
It is not a literal terrorism as in bobs and suicide bombers it was more like "terror from beyond" "nightmare on elm street" or "chainsaw" type of thing.
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

Fred vS

  • Hero Member
  • *****
  • Posts: 1675
    • miXimum is the DJ's best friend
Re: I do not like ^
« Reply #3 on: November 17, 2012, 05:52:48 am »
@ Leleldumbo
Quote
Read this,

Very clear, maybe the clearest explanation of Pascal concept i have read.
This man is genius.
« Last Edit: November 17, 2012, 05:54:31 am by Fred vS »
I use Lazarus 1.8.0 32/64 and FPC 3.0.3 32/64 on Linux Mint Mate 17 32/64, Windows 10, Windows 7 32/64, Windows XP 32,  FreeBSD 64 and Mac OS X Snow Leopard 32.
Widgetset: fpGUI, MSEgui, Win32, GTK2, Qt, Carbon.

https://github.com/fredvs

User137

  • Hero Member
  • *****
  • Posts: 1791
    • Nxpascal home
Re: I do not like ^
« Reply #4 on: November 17, 2012, 08:06:08 am »
The symbol ^ is fine, but i think i have to agree with Delphi's philosophy with it. When i have pointer to a class or record variable, i shouldn't need to use:
recordVarPtr^.Property but just recordVarPtr.Property
Because there is no other possible outcome from it than writing it with just dot. All i can see is that it makes it clear that we are dealing with pointed value. Pointer itself is just a memory address, there's no mistaking the dot usage for meaning the value only.

Leledumbo

  • Hero Member
  • *****
  • Posts: 8112
  • Programming + Glam Metal + Tae Kwon Do = Me
Re: I do not like ^
« Reply #5 on: November 17, 2012, 08:29:22 am »
Quote
The symbol ^ is fine, but i think i have to agree with Delphi's philosophy with it. When i have pointer to a class or record variable, i shouldn't need to use:
recordVarPtr^.Property but just recordVarPtr.Property
Delphi and TP already do that, so does their corresponding compatibility mode in Free Pascal (but AFAIK only if they're accessed as parameters).

anis2505

  • Full Member
  • ***
  • Posts: 201
Re: I do not like ^
« Reply #6 on: November 17, 2012, 09:57:59 am »
Hi,

this symbol is annoying. to me my keyboard is AZERTY and it's a French layout, to type the ^ I have to press it twice which produce ^^ and the I delete one of them. This is because this symbol not usually used in French only for some words like  être (to be in English).

regards
Dear Confucius you said {A picture is worth a thousand words}
I say {a good example is worth a thousand words}

eny

  • Hero Member
  • *****
  • Posts: 1587
Re: I do not like ^
« Reply #7 on: November 17, 2012, 10:25:51 am »
this symbol is annoying. to me my keyboard is AZERTY and it's a French layout, to type the ^ I have to press it twice which produce ^^ and the I delete one of them
Press ^ space...
All posts based on: Win10 (Win64); Lazarus 1.8.0 'stable' (#56594 win64) unless specified otherwise...

anis2505

  • Full Member
  • ***
  • Posts: 201
Re: I do not like ^
« Reply #8 on: November 17, 2012, 10:31:02 am »
this symbol is annoying. to me my keyboard is AZERTY and it's a French layout, to type the ^ I have to press it twice which produce ^^ and the I delete one of them
Press ^ space...

Thanks  :)
Dear Confucius you said {A picture is worth a thousand words}
I say {a good example is worth a thousand words}

Fred vS

  • Hero Member
  • *****
  • Posts: 1675
    • miXimum is the DJ's best friend
Re: I do not like ^
« Reply #9 on: November 17, 2012, 03:34:51 pm »
Quote
is annoying. to me my keyboard is AZERTY

Mine too  :-X.

By the way, i will not be against to change the symbol to point to a value  @variable  (who, for me, is property of internet) with something like  PtrtoVal(variable).

PS: I do not have absolutely nothing against symbols, it is just that, for me, using that kind of symbol is more in the  "C" mood than in Pascal.
« Last Edit: November 17, 2012, 03:42:25 pm by Fred vS »
I use Lazarus 1.8.0 32/64 and FPC 3.0.3 32/64 on Linux Mint Mate 17 32/64, Windows 10, Windows 7 32/64, Windows XP 32,  FreeBSD 64 and Mac OS X Snow Leopard 32.
Widgetset: fpGUI, MSEgui, Win32, GTK2, Qt, Carbon.

https://github.com/fredvs

Blaazen

  • Hero Member
  • *****
  • Posts: 2782
  • POKE 54296,15
    • Eye-Candy Controls
Re: I do not like ^
« Reply #10 on: November 17, 2012, 03:46:56 pm »
Quote
By the way, i will not be against to change the symbol to point to a value @ ...
You cannot replace ^ with @ .
Example:
Code: [Select]
VAR W : Word;
    P : ^Word;

BEGIN
   W:=10;
   P:=@W;
   WriteLn(P^);
   W:=30;
   WriteLn(P^);
   P^:=80;
   WriteLn(W);
END.
Example is taken from here: http://www.friends-of-fpc.org/articles/1040517/b/
Lazarus 2.1.0 r61214:62238 FPC 3.3.1 r40507 x86_64-linux-qt Chakra, Qt 4.8.7/5.13.2, Plasma 5.17.3
Lazarus 1.8.2 r57369 FPC 3.0.4 i386-win32-win32/win64 Wine 3.21

Try Eye-Candy Controls: https://sourceforge.net/projects/eccontrols/files/

Leledumbo

  • Hero Member
  • *****
  • Posts: 8112
  • Programming + Glam Metal + Tae Kwon Do = Me
Re: I do not like ^
« Reply #11 on: November 17, 2012, 03:50:40 pm »
Quote
By the way, i will not be against to change the symbol to point to a value  @variable  (who, for me, is property of internet) with something like  PtrtoVal(variable).
@ is already an "address of" operator, which is read naturally: @ is read "at", so @somevar reads "at somevar" which means the address of somevar. beautifully chosen, IMO.

Fred vS

  • Hero Member
  • *****
  • Posts: 1675
    • miXimum is the DJ's best friend
Re: I do not like ^
« Reply #12 on: November 17, 2012, 04:02:59 pm »
@ Blaazen

DeRefPtr(var) :=  ^var;
RefPtr(ptr)  := ptr^ ;
PtrtoVal(var) := @var ;


Code: [Select]
VAR W : Word;
    P : DeRefPtr(Word);

BEGIN
   W:=10;
   P:=PtrtoVal(W);
   WriteLn( RefPtr(P));
   W:=30;
   WriteLn(RefPtr(P));
 RefPtr(P):=80;
   WriteLn(W);
END.

PS : It is for the game, im happy with the existing convention, it is only a idea in the air...
« Last Edit: November 17, 2012, 04:14:22 pm by Fred vS »
I use Lazarus 1.8.0 32/64 and FPC 3.0.3 32/64 on Linux Mint Mate 17 32/64, Windows 10, Windows 7 32/64, Windows XP 32,  FreeBSD 64 and Mac OS X Snow Leopard 32.
Widgetset: fpGUI, MSEgui, Win32, GTK2, Qt, Carbon.

https://github.com/fredvs

Fred vS

  • Hero Member
  • *****
  • Posts: 1675
    • miXimum is the DJ's best friend
Re: I do not like ^
« Reply #13 on: November 17, 2012, 04:21:07 pm »
PS 2 @ Blaazen.

It seams that the comprehension of that symbols are difficult to interpret not only by humans.
All the translator from C to Pascal or Pascal to C that i have tested have problems with negotiation with this symbols while translation...
« Last Edit: November 17, 2012, 04:22:47 pm by Fred vS »
I use Lazarus 1.8.0 32/64 and FPC 3.0.3 32/64 on Linux Mint Mate 17 32/64, Windows 10, Windows 7 32/64, Windows XP 32,  FreeBSD 64 and Mac OS X Snow Leopard 32.
Widgetset: fpGUI, MSEgui, Win32, GTK2, Qt, Carbon.

https://github.com/fredvs

BigChimp

  • Hero Member
  • *****
  • Posts: 5740
  • Add to the wiki - it's free ;)
    • FPCUp, PaperTiger scanning and other open source projects
Re: I do not like ^
« Reply #14 on: November 17, 2012, 04:29:06 pm »
You can tell a person is integrated into a programming language when he starts making suggestion about how it should be changed.
You can tell a person has been using the language forever when he says to people making thos suggestions that there's a good reason why the original way was chosen.

Just joking ;)
Want quicker answers to your questions? Read http://wiki.lazarus.freepascal.org/Lazarus_Faq#What_is_the_correct_way_to_ask_questions_in_the_forum.3F

Open source including papertiger OCR/PDF scanning:
https://bitbucket.org/reiniero

Lazarus trunk+FPC trunk x86, Windows x64 unless otherwise specified