Recent

Author Topic: Re: language improvement suggestions (the spin off)  (Read 17254 times)

440bx

  • Hero Member
  • *****
  • Posts: 5077
Re: language improvement suggestions (the spin off)
« Reply #45 on: November 26, 2019, 06:40:41 am »
Ok, so to conclude...
Your analysis of the pros and cons of each construction is fair.  To conclude, I'm going to present a slightly different way of thinking about what makes a particular construct worthwhile.

Consider what happens when you see something like
Code: Pascal  [Select][+][-]
  1. for i := somevalue to someothervalue do ....
or
Code: Pascal  [Select][+][-]
  1. repeat
  2.   somestatement
  3. until somecondition
In both cases just seeing the "for" or the "repeat" tells you _instantly_ what you're looking at is a loop.

If instead you saw something like this
Code: Pascal  [Select][+][-]
  1. if somevar = somevalue then goto somelabel;
that instruction may be part of a loop implementation or something else that bears no resemblance to a loop.  Now, you have to examine the context to determine what the logical function of those instructions are, IOW, what structure, if any, they are used to implement.

The same thing happens with nested if/then/else(s), the fact that they are nested does not indicate a table structure.  It could be anything.  Using elsif does not change that which is why the graph does not change either.  The presence of "elsif" does not in any way guarantee a table structure.  The only thing it guarantees is a binary choice.

The omission of an "evaluate" statement in Pascal is a serious omission.  The reason is because multibranch conditional tables are fairly common in programming and the language lacks a construct that instantly informs the programmer that's the structure he/she is dealing with.  It is the same reason there is a "for", "repeat/until", "case", etc in the language, their presence instantly tells the programmer the structure he is dealing with, unlike what a "if somevar = somevalue then goto somelabel;" which gives no information whatsoever, thereby placing the burden on the programmer to determine what structure, if any, that sequence of instructions may be a part of.

Summary and conclusion:

Constructs such as "for", "repeat/until", "case", etc make programs easier to understand and more maintainable because they convey _more_ information and they also convey their purpose with precision and accuracy.  It's also important to note that they exist because those forms are very common in programming.   Those are the reasons there should be a conditional multi-branch statement, implemented with the "EVALUATE" statement in COBOL, in procedural computer languages. 

BTW, I enjoyed the discussion, thank you. :)

PS: what happened ? did this thread get split in two ?  Never mind, I just noticed it has been split in two.
« Last Edit: November 26, 2019, 06:42:24 am by 440bx »
(FPC v3.0.4 and Lazarus 1.8.2) or (FPC v3.2.2 and Lazarus v3.2) on Windows 7 SP1 64bit.

PascalDragon

  • Hero Member
  • *****
  • Posts: 5904
  • Compiler Developer
Re: Re: language improvement suggestions (the spin off)
« Reply #46 on: November 26, 2019, 10:05:13 am »
I know you're being sardonic. But let's try this again. This time with a relevant example:

Code: Pascal  [Select][+][-]
  1. //bad:
  2.  
  3. super.duper.big.mile.long.variable.that.fills.up.half.the.editor := super.duper.big.mile.long.variable.that.fills.up.half.the.editor - 1;
  4.  
  5. //better:
  6.  
  7. super.duper.big.mile.long.variable.that.fills.up.half.the.editor := this - 1;
  8.  

Can you dig it? I knew you could.  8-)

For this case, use with:

Code: Pascal  [Select][+][-]
  1. with super.duper.big.mile.long.variable.that.fills.up.half.the do
  2.   editor := editor - 1;

No need for new features for that...

Also it raises the question whether a hypothetical this would reevaluate the left side or not.

Thaddy

  • Hero Member
  • *****
  • Posts: 16653
  • Kallstadt seems a good place to evict Trump to.
Re: Re: language improvement suggestions (the spin off)
« Reply #47 on: November 26, 2019, 10:37:49 am »
Also it raises the question whether a hypothetical this would reevaluate the left side or not.

this is plain selfish ... :'(
with indicates cooperation.  :D
But I am sure they don't want the Trumps back...

Thaddy

  • Hero Member
  • *****
  • Posts: 16653
  • Kallstadt seems a good place to evict Trump to.
Re: language improvement suggestions (the spin off)
« Reply #48 on: November 26, 2019, 11:08:36 am »
"serious" how about {$TreatNestedCommentsAsCode <level>} ?
But I am sure they don't want the Trumps back...

marcov

  • Administrator
  • Hero Member
  • *
  • Posts: 12110
  • FPC developer.
Re: language improvement suggestions (the spin off)
« Reply #49 on: November 26, 2019, 11:10:42 am »
440bx: your answer doesn't really concern how much syntax is enough.

How many different ways must there minimally be to do the same thing?

Reasoning like this only leads to baroque languages. Free Pascal dialects is already way too large from language design perspective. Some is compatibility, some extensions to do everything (from embedded to enterprise to own RTL to native windows).

It is something else however to constantly keep adding redundant constructs because of heated plea on the forum and some nicely formatted concept code.

So let's reverse the question: how much is enough according to you?

Thaddy

  • Hero Member
  • *****
  • Posts: 16653
  • Kallstadt seems a good place to evict Trump to.
Re: language improvement suggestions (the spin off)
« Reply #50 on: November 26, 2019, 11:43:44 am »
440bx: your answer doesn't really concern how much syntax is enough.
As I wrote, be careful what and how many you wish for..
But I am sure they don't want the Trumps back...

kupferstecher

  • Hero Member
  • *****
  • Posts: 603
Re: Re: language improvement suggestions (the spin off)
« Reply #51 on: November 26, 2019, 11:55:30 am »
Using the right syntax saves a lot of typing
It's not about reduced tying, but better readability.

Code: Pascal  [Select][+][-]
  1. inc (aVar);
Code: Pascal  [Select][+][-]
  1. include (DrawGrid1.Font.Style, fsBold);
You actually made a point for "this". Now there are several intrinsics needed to more or less substitute the missing "this".
Personally I never use 'inc' and 'include' because of reduced readability. I rather type out the variables twice (which is not ideal, though).


For this case, use with:
The beauty of "this" is its simplicity. With "with" you actually add complexity, as you have to combine (when reading) the part written in the "with"-header with the member.
When using variables twice ore more in one statement, then (when reading the statement) you first have to understand that those are actually the same variables. The this-feature makes that very easy and intuitive.

Perhaps time by time you stumble over a line of code, remember my idea, and ask yourself if it could be helpful there.  :)

Also it raises the question whether a hypothetical this would reevaluate the left side or not.
An other plus of the concept, the compiler can fully optimise, as several "this"s describe a single access to the variable.

No need for new features for that
Yes, you could call it "that" instead of "this", I'm open to this.  ;)

440bx

  • Hero Member
  • *****
  • Posts: 5077
Re: language improvement suggestions (the spin off)
« Reply #52 on: November 26, 2019, 11:59:50 am »
440bx: your answer doesn't really concern how much syntax is enough.
Most important, it isn't about syntax.  It is about having constructs that express often encountered logic flow efficiently. 

How many different ways must there minimally be to do the same thing?
What a loaded question!  The answer is, as many as it takes until you find the simplest and optimal one.  That in turn implies there is a road to travel to get there.

I'll give an example, back in the times of Euclid, Algebra was actually done using Geometry.  Anyone who has read Euclid's "Elements" can see it in many of Euclid's proofs.  It should be very obvious that doing Algebra using geometric shapes is suboptimal, not to mention often inconvenient but, Euclid showed and proved it can be done. 

If someone were to apply the hidden premise present in your statement which is, anyway to do it is good enough and justifies not searching for better ways then, we'd be still be doing Algebra using geometrical shapes and, using that method, it is very doubtful we'd enjoy the pleasure (and aggravations) of having personal computers (among many other things.)

Reasoning like this only leads to baroque languages.
On the contrary.  It is your reasoning that leads to the enshrinement of "less than optimal" constructs. Just because you can make them work if you stand on your head and wave to a penguin 1800 miles south of Mecca  doesn't mean it's good enough.  Most people would consider that a "suboptimal" solution even if can get the job done.

Free Pascal dialects is already way too large from language design perspective. Some is compatibility, some extensions to do everything (from embedded to enterprise to own RTL to native windows).
That is true and, it is often the result of the desire to achieve some goal, such as Delphi compatibility, which may have originally been worthwhile but becomes dubious with time.

It is something else however to constantly keep adding redundant constructs because of heated plea on the forum and some nicely formatted concept code.
I definitely appreciate nicely formatted code that reflects the structure of the language but, a multi-branch construct has nothing to do with formatting, it has everything to do with function.  That said, just like any other construct, it is much nicer to see it well formatted than otherwise.

So let's reverse the question: how much is enough according to you?
That question can be answered but, not in a few lines.  To give an example of why, I'll apply your question to the field of Mathematics which gives, how much Mathematics is enough ?  the answer is not obvious and it greatly depends on what it will ultimately be applied to. 

It's important to be choosy but, that's a different thing than always being against everything. ;)

There is definitely "baggage" in FPC but, that should not be used as an excuse to get in the way of improvements.


(FPC v3.0.4 and Lazarus 1.8.2) or (FPC v3.2.2 and Lazarus v3.2) on Windows 7 SP1 64bit.

Martin_fr

  • Administrator
  • Hero Member
  • *
  • Posts: 10915
  • Debugger - SynEdit - and more
    • wiki
Re: language improvement suggestions (the spin off)
« Reply #53 on: November 26, 2019, 04:05:49 pm »
The same thing happens with nested if/then/else(s), the fact that they are nested does not indicate a table structure.  It could be anything.  Using elsif does not change that which is why the graph does not change either.  The presence of "elsif" does not in any way guarantee a table structure.  The only thing it guarantees is a binary choice.

Ok, that is a point.

My comments on "readability" where indeed only concerned, comparing the "when" list of values (which are used to form the individual conditions) with the way such conditions are expressed in "if".
Indeed if you want/need to express that the lookup is "case"/"table" like then you need that.

I take your word for "how common" it is. My personal experience does not seem to indicate it to be quite common....

del

  • Sr. Member
  • ****
  • Posts: 258
Re: Re: language improvement suggestions (the spin off)
« Reply #54 on: November 26, 2019, 07:09:18 pm »
Hi!

I am not sardonic. I only know that optimists have a deficit on informations.


And to your example:

wrong:
procedure Foo(Super: SomeType);

right:
procedure Foo (Editor: AnotherType);

Winni

OK. I put this on Google Translate and my browser crashed.

marcov

  • Administrator
  • Hero Member
  • *
  • Posts: 12110
  • FPC developer.
Re: language improvement suggestions (the spin off)
« Reply #55 on: November 26, 2019, 10:58:12 pm »
440bx: your answer doesn't really concern how much syntax is enough.
Most important, it isn't about syntax.  It is about having constructs that express often encountered logic flow efficiently. 

Yes. But I have serious concerns with the "often" of that argument. And if it is not often, it can be better made with combinations of existing logic, instead of having larger, mostly unused constructs.

As Rainbow6 says, very complex nested ifs are not that common in Pascal code. (in Verilog, however....). I share his experience (from working on car auctioning site) that such discount schemes, pricing etc are usually stored in sql tables and not hardcoded in code.

I nowhere have complex nested decision trees in my code.

How many different ways must there minimally be to do the same thing?
What a loaded question!  The answer is, as many as it takes until you find the simplest and optimal one.  That in turn implies there is a road to travel to get there.

As loaded as the message I reacted to that talks about "Serious omission", when it is the first time suggested in 25 years.

If someone were to apply the hidden premise present in your statement which is, anyway to do it is good enough and justifies not searching for better ways then, we'd be still be doing Algebra using geometrical shapes and, using that method, it is very doubtful we'd enjoy the pleasure (and aggravations) of having personal computers (among many other things.)

Yes, but I fail to see how to connects to this problem. People don't switch to programming only using evaluate statements (and frankly, they are welcome to Cobol if they want to)

IOW your suggestion is more because Euclidian proofs of algebra had some merit, everybody should always lug along his set of golden geometric rulers and polish them three times a day.

Maintenance of language costs effort. Seldomly used constructs are therefore not good candidates for inclusion.

Reasoning like this only leads to baroque languages.
On the contrary.  It is your reasoning that leads to the enshrinement of "less than optimal" constructs. Just because you can make them work if you stand on your head and wave to a penguin 1800 miles south of Mecca  doesn't mean it's good enough.  Most people would consider that a "suboptimal" solution even if can get the job done.

I'm sure there are linux users in Saudi Arabia nowadays :-) Somewhere somebody has a phone with a penguin. Try waving a fish otherwise :-)

Free Pascal dialects is already way too large from language design perspective. Some is compatibility, some extensions to do everything (from embedded to enterprise to own RTL to native windows).
That is true and, it is often the result of the desire to achieve some goal, such as Delphi compatibility, which may have originally been worthwhile but becomes dubious with time.

I don't agree. It will become more important than ever. When people desert Delphi, a close relative is easier than a far away. You'll never get all (or even most) of them, but increasing artificial barriers won't help.

Stronger even. If I had my way, I'd abolished the mostly redundant FPC and OBJFPC modes 10 years ago. The only thing worse than having a bad language construct is having a bad AND a good replacement for the same construct.

It is something else however to constantly keep adding redundant constructs because of heated plea on the forum and some nicely formatted concept code.
I definitely appreciate nicely formatted code that reflects the structure of the language but, a multi-branch construct has nothing to do with formatting, it has everything to do with function.  That said, just like any other construct, it is much nicer to see it well formatted than otherwise.

It is easy to make a case seem compelling with an example where it actually saves some chars and looks somewhat ok. It doesn't mean that that economics example is the expected average situation.

So let's reverse the question: how much is enough according to you?
That question can be answered but, not in a few lines.  To give an example of why, I'll apply your question to the field of Mathematics which gives, how much Mathematics is enough ?  the answer is not obvious and it greatly depends on what it will ultimately be applied to. 

Well, I want you to put yourself in the shoes of a custodian of a programming dialect, and try to come up with rules what is logical and what not. You may even use Mathematics.

Quote
It's important to be choosy but, that's a different thing than always being against everything. ;)

There is definitely "baggage" in FPC but, that should not be used as an excuse to get in the way of improvements.

People that want something always call it an improvement. If you are the only one in 25 years, there is a good chance it isn't  >:D

440bx

  • Hero Member
  • *****
  • Posts: 5077
Re: language improvement suggestions (the spin off)
« Reply #56 on: November 27, 2019, 06:15:41 am »
@Marcov

I just want to let you know that I spent close to an hour to compose an extensive, well thought out and fully supported reply to the points you made and, a <backspace> at the wrong time caused the browser to go to the previous page and, when I clicked on the forward button, all of my reply was gone!.  What a bummer!.  oh well... it is what it is.

I mention that only because I want you to know that I put as much effort in composing a reply as you did to produce your post.

When I considered re-typing everything, not something I particularly looked forward to, the fact that nothing I say is going to make any difference in the current status quo was good enough reason not to.  My apologies for a short reply that doesn't do justice to your post.  That said, I will re-address your last two points (though the content is different than what I had originally stated.)


Well, I want you to put yourself in the shoes of a custodian of a programming dialect, and try to come up with rules what is logical and what not. You may even use Mathematics.
I wish I could come up with a mathematical model (like Euclid's "Elements" for Geometry) of how to design a computer language.  Unfortunately, I can't, simply not smart enough to realize that feat.  That's when I wish Leonhard Euler were alive, he was probably smart enough to figure out a complete mathematical model to accomplish that.  It's amazing how smart that guy was.

I will only state that, among other things, graph theory, set theory and linear algebra can be used to represent some parts of a computer language but, not all of it.  Due to the incompleteness, their usefulness is limited.

Other than that, I will state that I disagree with most of everything you said.  I'm sure that is not a surprise but, I wanted it to be clear anyway.

People that want something always call it an improvement. If you are the only one in 25 years, there is a good chance it isn't  >:D
That's quite a fallacy.  Thousands of years went by before Rene Descartes showed how to unify Algebra and Geometry.  The fact that thousand of years went by before he did is, obviously, not a measure of the method's merit.  The same can be said about a large number of Mathematical and Engineering constructs.

What follows is simply a personal opinion, I believe you should consider being a little more open to changes in the language.  The premises you consistently use to justify not including any new features in Pascal are either demonstrably false or of dubious value.

Best regards.
(FPC v3.0.4 and Lazarus 1.8.2) or (FPC v3.2.2 and Lazarus v3.2) on Windows 7 SP1 64bit.

PascalDragon

  • Hero Member
  • *****
  • Posts: 5904
  • Compiler Developer
Re: Re: language improvement suggestions (the spin off)
« Reply #57 on: November 27, 2019, 09:28:44 am »
Also it raises the question whether a hypothetical this would reevaluate the left side or not.
An other plus of the concept, the compiler can fully optimise, as several "this"s describe a single access to the variable.
You didn't get my point. Take this:
Code: Pascal  [Select][+][-]
  1. SomeFunctionThatReturnsAnObject.SomeProperty := SomeFunctionThatReturnsAnObject.SomeProperty + 1;
Now SomeFunctionThatReturnsAnObject could have side effects. If the hypothetical "this" evaluates the left side only once then this would lead to a different result. Also speaking of properties there is a reason why we disallowed the use of properties for the C-style operators. The "this" is essentially the same. Thus it would only be really useful for variables and thus it's definitely not worth the effort.

del

  • Sr. Member
  • ****
  • Posts: 258
Re: Re: language improvement suggestions (the spin off)
« Reply #58 on: November 27, 2019, 12:22:04 pm »
I know you're being sardonic. But let's try this again. This time with a relevant example:

Code: Pascal  [Select][+][-]
  1. //bad:
  2.  
  3. super.duper.big.mile.long.variable.that.fills.up.half.the.editor := super.duper.big.mile.long.variable.that.fills.up.half.the.editor - 1;
  4.  
  5. //better:
  6.  
  7. super.duper.big.mile.long.variable.that.fills.up.half.the.editor := this - 1;
  8.  

Can you dig it? I knew you could.  8-)

For this case, use with:

Code: Pascal  [Select][+][-]
  1. with super.duper.big.mile.long.variable.that.fills.up.half.the do
  2.   editor := editor - 1;

No need for new features for that...

Also it raises the question whether a hypothetical this would reevaluate the left side or not.

Hmm ... I like vertical compactness, too. Maybe I gave a poor example. We already have these: +=, -=, /=, and *= (i.e., you're already a little "pregnant"). What about this?

Code: Pascal  [Select][+][-]
  1. //bad:
  2. big.fat.ugly.horizontally.bloaty.pythonlike.variable := sqrt(big.fat.ugly.horizontally.bloaty.pythonlike.variable);
  3.  
  4. //better:
  5. big.fat.ugly.horizontally.bloaty.pythonlike.variable := sqrt(this);
  6.  



guest64953

  • Guest
Re: language improvement suggestions (the spin off)
« Reply #59 on: November 27, 2019, 02:36:51 pm »
Sorry, guys. I'm just a noob but may I suggest we should follow the freebasic's way of creating new object pascal dialects? Please keep the current objfpc dialect as is and testing the new features with {$mode objfpc-next} ? We should add a switch to the compiler, e.g. fpc -lang objfpc-next ? I know someday objfpc-next have to be merge with objfpc but I don't think it's the way it should be. I prefer the objective c way, we may rename our current objfpc dialect with objfpc1 and the new dialect should be objfpc2. It's the best way I could imagine.

 

TinyPortal © 2005-2018