Recent

Author Topic: Go-flavored Pascal: now with Raylib bindings  (Read 7668 times)

circular

  • Hero Member
  • *****
  • Posts: 4195
    • Personal webpage
Re: Go-flavored Pascal: now with Raylib bindings
« Reply #15 on: April 01, 2020, 11:43:04 pm »
By the way, while you're at it, why not remove the ";" ?
Is the semicolon so annoying for you? Even more than begin...end instead of (now common) {...} ? :)
I'll think of it, but the semicolon cannot be completely removed - it can be made optional. The compiler source will have them anyway, since I need to keep it compatible with Delphi/FPC.
That's a suggestion as I was thinking of writing a parser to make Pascal easier. Removing the semicolon was part of it.

If find the semicolon not really annoying but useless. I would almost never use it. And recently a semicolon lost after a "then" was an error difficult to spot.

There are so few cases where you could need it. So I really wanted to remove it, not making it optional. What are the use cases anyway?
Code: Delphi  [Select][+][-]
  1. if sometest then ;
Code: Delphi  [Select][+][-]
  1. for i := 1 to 10 do ;
What's the point of that?

Maybe
Code: Delphi  [Select][+][-]
  1. if sometest then if sometest2 then DoA; else DoB
But then you could anyway do it with begin/end making it much more readable.

Or I am missing something?
« Last Edit: April 01, 2020, 11:44:39 pm by circular »
Conscience is the debugger of the mind

marcov

  • Administrator
  • Hero Member
  • *
  • Posts: 11383
  • FPC developer.
Re: Go-flavored Pascal: now with Raylib bindings
« Reply #16 on: April 01, 2020, 11:57:19 pm »

Or I am missing something?

- Dangling else?
- multiline statements?
- error handling?
- compatibility ? And if you change this, why try being compatible or even pascal at all?

circular

  • Hero Member
  • *****
  • Posts: 4195
    • Personal webpage
Re: Go-flavored Pascal: now with Raylib bindings
« Reply #17 on: April 02, 2020, 12:14:54 am »
- Dangling else?
Give me an example as I have done, please. That's too easy otherwise.

Quote
- multiline statements?
You don't need a semicolon for that :
Code: Delphi  [Select][+][-]
  1. a := 2   b := 3
would compile just fine. Though one could allow a semi-colon if there is some text afterwards, to make it more readable.

Quote
- error handling?
Please expand.

Quote
- compatibility ? And if you change this, why try being compatible or even pascal at all?
That's just polarizing the debate and you are aware of it. I like Pascal, there are just some things that can be improved.
Conscience is the debugger of the mind

vtereshkov

  • New member
  • *
  • Posts: 8
Re: Go-flavored Pascal: now with Raylib bindings
« Reply #18 on: April 02, 2020, 12:41:01 am »

Or I am missing something?

- Dangling else?
- multiline statements?
- error handling?
- compatibility ? And if you change this, why try being compatible or even pascal at all?

I think the most dangerous form of 'dangling else' is when it's inside the case statement. The output of the example below depends on whether there is a semicolon before else or not.
Code: Pascal  [Select][+][-]
  1. var
  2.   a: integer = 1;
  3.  
  4. begin
  5. case a of
  6.   1, 2: if a = 2 then
  7.           writeln(2);
  8.         else
  9.           writeln(1);
  10. end;            
  11. end.

winni

  • Hero Member
  • *****
  • Posts: 3197
Re: Go-flavored Pascal: now with Raylib bindings
« Reply #19 on: April 02, 2020, 02:35:32 am »
Hi!

I repeat myself but:

The else in the case statement is and was a bad idea.
It was introduced by Turbo Pascal.

The Pascal syntax is otherwise.

Just abolish the else in case.

Winni

« Last Edit: April 02, 2020, 02:37:05 am by winni »

eljo

  • Sr. Member
  • ****
  • Posts: 468
Re: Go-flavored Pascal: now with Raylib bindings
« Reply #20 on: April 02, 2020, 04:10:24 am »
Hi!

I repeat myself but:

The else in the case statement is and was a bad idea.
It was introduced by Turbo Pascal.

The Pascal syntax is otherwise.

Just abolish the else in case.

Winni
the pascal syntax did not support classes either they where introduced with delphi 1 it did not support objects, advenced records and a list of other features too. That's a week excuse of an argument don't you think?

440bx

  • Hero Member
  • *****
  • Posts: 3944
Re: Go-flavored Pascal: now with Raylib bindings
« Reply #21 on: April 02, 2020, 04:10:30 am »
- error handling?
Please expand.
Getting rid of the semicolon in Pascal is not a good idea.  The reason is, a semicolon tells the compiler a statement has ended.  Without the semicolon, the compiler has to figure out a statement has ended using context, that alone is likely not possible in all cases and, even if possible, it would complicate the compiler's code. 


vtereshkov provided a good example of that in his last post.  In the code:
Code: Pascal  [Select][+][-]
  1. var
  2.   a: integer = 1;
  3.  
  4. begin
  5. case a of
  6.   1, 2: if a = 2 then
  7.           writeln(2);
  8.         else
  9.           writeln(1);
  10. end;            
  11. end.
if there were no semicolons, how could the compiler decide if the "else" associates with the "if" or the "case" ?

Another example that comes to mind which I personally use all the time is this:
Code: Pascal  [Select][+][-]
  1. if somecondition then
  2. {$IFDEF FORCE_CONDITION} ; {$ENDIF}
  3. begin
  4.   <statements to handle the condition>
  5. end;
  6.  
that way I can ensure the code can handle the condition without having to create a test case for it, which in some cases can be very difficult and/or time consuming, to ensure the code works.  By optionally inserting that semicolon after the "then" I can activate the code.

Spaces and newlines make for lousy separators.

Maybe that also gives an idea to those who put the "then" and "begin" keywords on the same line, why doing that is not a good idea either, nor good "style" for that matter.
(FPC v3.0.4 and Lazarus 1.8.2) or (FPC v3.2.2 and Lazarus v3.2) on Windows 7 SP1 64bit.

bytebites

  • Hero Member
  • *****
  • Posts: 632
Re: Go-flavored Pascal: now with Raylib bindings
« Reply #22 on: April 02, 2020, 08:12:16 am »
Code: Pascal  [Select][+][-]
  1. var
  2.   a: integer = 1;
  3.  
  4. begin
  5. case a of
  6.   1, 2: if a = 2 then
  7.           writeln(2);
  8.         otherwise
  9.           writeln(1);
  10. end;            
  11. end.

Use otherwise with case to make meaning clear.


440bx

  • Hero Member
  • *****
  • Posts: 3944
Re: Go-flavored Pascal: now with Raylib bindings
« Reply #23 on: April 02, 2020, 08:39:40 am »
Use otherwise with case to make meaning clear.
I agree.  I used that example to show that getting rid of semicolons in Pascal is not as simple as it first seems to be.  Removing the "else" option from the "case" statement would definitely break backwards compatibility which is obviously not desirable.

Additional, there would no longer be a simple option to cause compound statements in an "if" to be conditionally executed (shown in the second example)
(FPC v3.0.4 and Lazarus 1.8.2) or (FPC v3.2.2 and Lazarus v3.2) on Windows 7 SP1 64bit.

marcov

  • Administrator
  • Hero Member
  • *
  • Posts: 11383
  • FPC developer.
Re: Go-flavored Pascal: now with Raylib bindings
« Reply #24 on: April 02, 2020, 09:39:58 am »
Quote
- compatibility ? And if you change this, why try being compatible or even pascal at all?
That's just polarizing the debate and you are aware of it. I like Pascal, there are just some things that can be improved.

This whole subthread is polarizing, making minor syntax details seem to be the center of the world.

The point is and remains if you "improve" it (and that is a very subjective word), it is no longer Pascal, and Modula2 is not that far from Pascal, but then with better blockstructure. See e.g. Oxygene with its changing procedure to method for objects etc.

You are either compatible, or not. Even if you label "not compatible" as "improved" to make it sound nicer.

But I'd leave this the same for compatibility's sake, and if it is that important for you, and it is that easy/automatic, enhance an editor to do it for you.

Note that the nested IF dangling else only matters to keep the scanner part more context free https://en.wikipedia.org/wiki/Dangling_else

But maybe that is less important if you do away the ;, then you have to reevaluate the grammar entirely anyway.
« Last Edit: April 02, 2020, 10:07:49 am by marcov »

circular

  • Hero Member
  • *****
  • Posts: 4195
    • Personal webpage
Re: Go-flavored Pascal: now with Raylib bindings
« Reply #25 on: April 02, 2020, 10:33:54 am »
I think the most dangerous form of 'dangling else' is when it's inside the case statement. The output of the example below depends on whether there is a semicolon before else or not.
Code: Pascal  [Select][+][-]
  1. var
  2.   a: integer = 1;
  3.  
  4. begin
  5. case a of
  6.   1, 2: if a = 2 then
  7.           writeln(2);
  8.         else
  9.           writeln(1);
  10. end;            
  11. end.
Indeed. In fact, that would be the only compelling argument for keeping the semicolon.

The else in the case statement is and was a bad idea.
It was introduced by Turbo Pascal.

The Pascal syntax is otherwise.

Just abolish the else in case.
Oh I did not know I could use otherwise here. That feels safer indeed.  :)

Another example that comes to mind which I personally use all the time is this:
Code: Pascal  [Select][+][-]
  1. if somecondition then
  2. {$IFDEF FORCE_CONDITION} ; {$ENDIF}
  3. begin
  4.   <statements to handle the condition>
  5. end;
  6.  
that way I can ensure the code can handle the condition without having to create a test case for it, which in some cases can be very difficult and/or time consuming, to ensure the code works.  By optionally inserting that semicolon after the "then" I can activate the code.
Interesting trick. Though you can also do:
Code: Delphi  [Select][+][-]
  1. {$IFNDEF FORCE_CONDITION}
  2. if somecondition then
  3. {$ENDIF}
  4. begin
  5.   <statements to handle the condition>
  6. end;
  7.  

This whole subthread is polarizing, making minor syntax details seem to be the center of the world.
You're trying the mirror effect now.

Nope I did not intend to make a whole subthread or make it the center of the world. It just seems that people care and have interesting things to say about it.

Quote
The point is and remains if you "improve" it (and that is a very subjective word), it is no longer Pascal, and Modula2 is not that far from Pascal, but then with better blockstructure. See e.g. Oxygene with its changing procedure to method for objects etc.
I am not forcing the idea. We could vote on it and that could be a compiler switch.

Quote
You are either compatible, or not. Even if you label "not compatible" as "improved" to make it sound nicer.
There you go again polarizing.

Quote
But I'd leave this the same for compatibility's sake, and if it is that important for you, and it is that easy/automatic, enhance an editor to do it for you.
I have been thinking about it.

Quote
Note that the nested IF dangling else only matters to keep the scanner part more context free https://en.wikipedia.org/wiki/Dangling_else
In fact I don't see how it changes anything because the ; is not allowed anyway before else.

I created a new topic:
https://forum.lazarus.freepascal.org/index.php/topic,49153.0.html
« Last Edit: April 02, 2020, 10:54:39 am by circular »
Conscience is the debugger of the mind

440bx

  • Hero Member
  • *****
  • Posts: 3944
Re: Go-flavored Pascal: now with Raylib bindings
« Reply #26 on: April 02, 2020, 10:54:14 am »
Interesting trick. Though you can also do:
Code: Delphi  [Select][+][-]
  1. {$IFNDEF FORCE_CONDITION}
  2. if somecondition then
  3. {$ENDIF}
  4. begin
  5.   <statements to handle the condition>
  6. end;
  7.  
Yes but, that takes two lines.  With the one I use, I can have the directive in one line in the editor's buffer and insert very quickly in all the "if" statements whose statements I want to test and, removing it if necessary only requires deleting one line.  Faster, more efficient.   Long live the semicolon. :)
(FPC v3.0.4 and Lazarus 1.8.2) or (FPC v3.2.2 and Lazarus v3.2) on Windows 7 SP1 64bit.

circular

  • Hero Member
  • *****
  • Posts: 4195
    • Personal webpage
Re: Go-flavored Pascal: now with Raylib bindings
« Reply #27 on: April 02, 2020, 10:56:53 am »
Yes but, that takes two lines.  With the one I use, I can have the directive in one line in the editor's buffer and insert very quickly in all the "if" statements whose statements I want to test and, removing it if necessary only requires deleting one line.  Faster, more efficient.   Long live the semicolon. :)
:D I can see why you would not want to enable the compiler directive semicolon-free.  :)
Conscience is the debugger of the mind

marcov

  • Administrator
  • Hero Member
  • *
  • Posts: 11383
  • FPC developer.
Re: Go-flavored Pascal: now with Raylib bindings
« Reply #28 on: April 02, 2020, 12:01:50 pm »
This whole subthread is polarizing, making minor syntax details seem to be the center of the world.
You're trying the mirror effect now.

Nope. Simply two standards. Everybody but you has hidden agenda, your actions are indisputable. I'm wondering what "effect" you'll think up for this.

Quote
Nope I did not intend to make a whole subthread or make it the center of the world. It just seems that people care and have interesting things to say about it.

If you accept the basis premise that it is a serious problem. The thread is terribly light on this.

Quote
I am not forcing the idea. We could vote on it and that could be a compiler switch.

Ok, I didn't know mr. vtereshkov accepted such features by vote.

Quote
Quote
You are either compatible, or not. Even if you label "not compatible" as "improved" to make it sound nicer.
There you go again polarizing.

I'm not polarizing. It is a fact. Unless you want to accuse other pascal compilers not accepting the dialect anymore as polarizing. Naughty, naughty parsers.

Quote
Quote
But I'd leave this the same for compatibility's sake, and if it is that important for you, and it is that easy/automatic, enhance an editor to do it for you.
I have been thinking about it.

I can see the use for it if you run it on e.g. selected blocks to enhance quotes. E.g. to fix them after other substitutions etc.

Quote
Quote
Note that the nested IF dangling else only matters to keep the scanner part more context free https://en.wikipedia.org/wiki/Dangling_else
In fact I don't see how it changes anything because the ; is not allowed anyway before else.

That is solved in a different (semantic) layer. Read the article.

Quote
I created a new topic:
https://forum.lazarus.freepascal.org/index.php/topic,49153.0.html

I had the errorhandling point to elaborate, I did it in that thread.

circular

  • Hero Member
  • *****
  • Posts: 4195
    • Personal webpage
Re: Go-flavored Pascal: now with Raylib bindings
« Reply #29 on: April 02, 2020, 09:42:43 pm »
Nope. Simply two standards. Everybody but you has hidden agenda, your actions are indisputable. I'm wondering what "effect" you'll think up for this.
I have no idea what you're talking about.

Quote
If you accept the basis premise that it is a serious problem. The thread is terribly light on this.
I don't consider it to be a serious problem. I am just talking freely.

Quote
I'm not polarizing. It is a fact. Unless you want to accuse other pascal compilers not accepting the dialect anymore as polarizing. Naughty, naughty parsers.
Judgements are not the way to go my friend.
Conscience is the debugger of the mind

 

TinyPortal © 2005-2018