Recent

Author Topic: Object Pascal decline?  (Read 155678 times)

Avishai

  • Hero Member
  • *****
  • Posts: 1021
Re: Object Pascal decline?
« Reply #15 on: November 28, 2013, 12:59:19 pm »
As far as a petition is concerned, that isn't something I would like to see happen.  The developers are overwhelmed with issues that effect the existing Lazarus users and they must come first.  In my opinion, what needs to happen is to attract the attention of a REAL programmer that is also a R2L person.  I keep trying but so far I'm knocking on closed doors.
Lazarus Trunk / fpc 2.6.2 / Win32

vicot

  • Full Member
  • ***
  • Posts: 114
Re: Object Pascal decline?
« Reply #16 on: November 28, 2013, 01:03:29 pm »
  • In-block variable declarations. for var i := 1 to .. do, the current way of declaring variables is scaring everyone who used a c-like away

could you please elaborate on this?

BeniBela

  • Hero Member
  • *****
  • Posts: 921
    • homepage
Re: Object Pascal decline?
« Reply #17 on: November 28, 2013, 02:01:26 pm »
Full RightToLeft support means Mirroring controls so that they are drawn R2L, starting with the TForm and continuing through every visual control that has a direction. 

In that direction, another required feature is a layout manager. Like putting all controls in a grid layout (similar to qt/java, but more complex layouts are also possible).


Then you could mirror the controls platform-independent.



You might think the current anchor system is more powerful, but it does not really work if you have many platforms. You cannot make any assumption. On some systems an edit might be bigger than a label, on some systems, the label is  bigger than the edit, on some the form is too small, on others to big, on some the controls should be horizontally aligned, on some vertically...
There is no place you can reliable anchor to.





  • In-block variable declarations. for var i := 1 to .. do, the current way of declaring variables is scaring everyone who used a c-like away

could you please elaborate on this?

Well, in Pascal every variable needs to be declared before the begin block.

Code: [Select]
var i: integer;
begin
  for i := 1 to 10 do ...
end;

But in almost every other programming language, you declare the variable where you use it:

Code: [Select]
  for (int i = 1; i <= 10; i++) ...

This prevents errors by using uninitialized variables, errors by using the wrong variable later (because it would be out of scope), and most important it is what people are used to nowadays, so they do not like to switch to a language not supporting it.

The syntax would be to allow var, wherever you assign to a variable, having the same effect as putting the var before the begin.

Code: [Select]
begin
  for var i := 1 to 10 do ...
end;


And it would not be limited to for

Code: [Select]
begin
  var s := '12345';
  for var i := 1 to length(s) do begin
    var c := s[i];
    var c_with_another_type: string := s[i];
  end;
end;

vicot

  • Full Member
  • ***
  • Posts: 114
Re: Object Pascal decline?
« Reply #18 on: November 28, 2013, 02:24:30 pm »
The syntax would be to allow var, wherever you assign to a variable, having the same effect as putting the var before the begin.

Code: [Select]
begin
  for var i := 1 to 10 do ...
end;


And it would not be limited to for

Code: [Select]
begin
  var s := '12345';
  for var i := 1 to length(s) do begin
    var c := s[i];
    var c_with_another_type: string := s[i];
  end;
end;

What you propose is interesting. I think a reasonable compromise could be to have the declarations that you propose as local variables, explicitly declared as such. This is already done in some languages, e.g. Lua. Instead of 'var', we could use 'local'.


garlar27

  • Hero Member
  • *****
  • Posts: 652
Re: Object Pascal decline?
« Reply #19 on: November 28, 2013, 02:30:08 pm »
So you want to introduce the worst part of "C like" languages?
And with that you think a hord of programers will switch to FPC??
« Last Edit: November 28, 2013, 02:31:40 pm by garlar27 »

Avishai

  • Hero Member
  • *****
  • Posts: 1021
Re: Object Pascal decline?
« Reply #20 on: November 28, 2013, 02:34:25 pm »
Pre-Declaring Pascal Vars has always been considered one of it's strengths.  Changing that would be a huge mistake.  If you want to write C, write C. 
Lazarus Trunk / fpc 2.6.2 / Win32

typo

  • Hero Member
  • *****
  • Posts: 3051
Re: Object Pascal decline?
« Reply #21 on: November 28, 2013, 02:36:13 pm »
I agree.

vicot

  • Full Member
  • ***
  • Posts: 114
Local variables (was: Object Pascal decline?)
« Reply #22 on: November 28, 2013, 02:43:49 pm »
So you want to introduce the worst part of "C like" languages?

garlar27, believe me: I also don't like C-like languages, and I love Pascal's strict discipline. I would not want to have variable declarations scattered all over the program, as it would really be untidy and confusing. I like to know where my variables are declared. BUT with local variables it would be a totally different case, because of their limited scope. At least within the loops, I don't think that there would be any problem with that.
Having said this, I admit that I am a newbie and that my opinion is worth LESS than 2 cents. Feel free to criticize it.


BeniBela

  • Hero Member
  • *****
  • Posts: 921
    • homepage
Re: Object Pascal decline?
« Reply #23 on: November 28, 2013, 02:59:04 pm »
Pre-Declaring Pascal Vars has always been considered one of it's strengths.  Changing that would be a huge mistake.  If you want to write C, write C. 

Such comments are one of the reason for the decline!


And with that you think a hord of programers will switch to FPC??

At least it is one of the reason they are not switching

vicot

  • Full Member
  • ***
  • Posts: 114
Re: Object Pascal decline?
« Reply #24 on: November 28, 2013, 03:02:44 pm »
I think we should not be focusing on what is more pleasing or appealing to others, but rather on what is more convenient for us. I was not endorsing the local variables in order to attract programmers from C-like languages, but because it seemed a nice and convenient feature to me.
Or should we rule out such a feature only because it is present in C-like languages?

marcov

  • Administrator
  • Hero Member
  • *
  • Posts: 12050
  • FPC developer.
Re: Object Pascal decline?
« Reply #25 on: November 28, 2013, 03:22:28 pm »
Or should we rule out such a feature only because it is present in C-like languages?

No, because it doesn't fit with the Pascal block oriented parsing model, and its use is doubtful, and there are other ways to change this for the ones that like taht (e.g. Delphi has a keycombo to autodeclare it)

Avishai

  • Hero Member
  • *****
  • Posts: 1021
Re: Object Pascal decline?
« Reply #26 on: November 28, 2013, 03:23:51 pm »
Lazarus Trunk / fpc 2.6.2 / Win32

vicot

  • Full Member
  • ***
  • Posts: 114
Re: Object Pascal decline?
« Reply #27 on: November 28, 2013, 03:25:07 pm »
[...] Delphi has a keycombo to autodeclare it [...]

This is certainly interesting. Could we have it in Lazarus too?

garlar27

  • Hero Member
  • *****
  • Posts: 652
Re: Object Pascal decline?
« Reply #28 on: November 28, 2013, 03:26:25 pm »

And with that you think a hord of programers will switch to FPC??

At least it is one of the reason they are not switching
The true reason is that they don't want to learn new things.
In addition, they are lazy enough to not take the challenge of do things a little different.

And changing Pascal for a sort of "Cool Paskal" won't work. Because People hates the "wanna bes" and "pretenders".

Pascal was a very popular language during the "The Delphi Golden Age" and all C programers who switched to Delphi never complained about that. Further more they where happy with almost everything in Object Pascal, except that they wanted multiple inheritance and garbage collector.

<OFF_TOPIC RantMode="ON">
I think there's something wrong with the educational system in the world nowadays. Everybody wants (demands) that the whole world adapt to what they know or can do instead of adapt, learn or change them selves when the problem, scenario changes.
</OFF_TOPIC>

marcov

  • Administrator
  • Hero Member
  • *
  • Posts: 12050
  • FPC developer.
Re: Object Pascal decline?
« Reply #29 on: November 28, 2013, 03:38:28 pm »
[...] Delphi has a keycombo to autodeclare it [...]

(in case sb has Delphi and wants to test, it is ctrl-shift-V, but it might be D2009, maybe D2006+.  A dialog pops up, but integer is the default, so ideal for loop vars, just hit enter again)

Quote
This is certainly interesting. Could we have it in Lazarus too?

If sb would care enough to implement, probably yes. It is open source :-) 

Patches can be submitted via the bugtracker.

 

TinyPortal © 2005-2018