Recent

Author Topic: If ShortInt and Boolean then  (Read 1186 times)

Blaazen

  • Hero Member
  • *****
  • Posts: 2994
  • POKE 54296,15
    • Eye-Candy Controls
Re: If ShortInt and Boolean then
« Reply #15 on: October 19, 2020, 04:42:06 pm »
It makes code more readable:
Code: Pascal  [Select][+][-]
  1. if something
  2. if something<>0
  3. if assigned(something)
It is obvious what type it is (boolean/number/pointer) without looking to declaration or hovering the identifier.

I just have one idea/proposal: Would it be possible to add one field to status bar of Source Editor to display the declaration of current identifier? ("current" here means the position of the caret, not the mouse pointer). Image explains it.
Lazarus 2.1.0 r64115 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/

Handoko

  • Hero Member
  • *****
  • Posts: 3909
  • My goal: build my own game engine using Lazarus
Re: If ShortInt and Boolean then
« Reply #16 on: October 19, 2020, 05:46:05 pm »
That sounds good but my Source Editor's status bar is already crowded. Also, similarly but less informatively the information can be shown using ctrl+space.

jamie

  • Hero Member
  • *****
  • Posts: 3791
Re: If ShortInt and Boolean then
« Reply #17 on: October 19, 2020, 05:55:40 pm »
if not for anything else that keeps getting rejected..

The helpers for types could at least have a default to them...

so for an integer.Default = (self <> 0);

StringHelper.Default= (self <> '');

etc
The only true wisdom is knowing you know nothing

PascalDragon

  • Hero Member
  • *****
  • Posts: 2418
  • Compiler Developer
Re: If ShortInt and Boolean then
« Reply #18 on: October 20, 2020, 09:48:24 am »
Don't let anyone like jamie ever touch the language and the compiler, as once given, it's a step forward towards having truthy and falsy values and rules (hello, PHP! Python! JavaScript! And everyone else with this stupidity!) that make boolean evaluation complex to implement, understand and memorize.

Don't worry, before we let people touch the compiler themselves we require them to show that they can produce code that's dedicated to the correct spirit of Pascal.

The helpers for types could at least have a default to them...

so for an integer.Default = (self <> 0);

StringHelper.Default= (self <> '');

No, because something like that would lead to just as much confusion for both the user and the compiler.

 

TinyPortal © 2005-2018