Recent

Author Topic: Making the semicolon useless  (Read 10375 times)

circular

  • Hero Member
  • *****
  • Posts: 3329
    • Personal webpage
Re: Making the semicolon useless
« Reply #90 on: April 07, 2020, 02:08:17 pm »
2. The semicolon as a statement terminator is very useful, both from a readability and from a practical point of view. Consider the following BASIC example without semicolon support:
Code: FreeBasic  [Select][+][-]
  1. buf = "command " _
  2.   + spec _
  3.   + ext _
  4.   + libs _
  5.   + switch _
  6.   + outp
... and the same with semicolon support:
Code: FreeBasic  [Select][+][-]
  1. buf = "command "
  2.   + spec
  3.   + ext
  4.   + libs
  5.   + switch
  6.   + outp;
This was fixed in VB.Net by guessing line continuation. Now you very rarely need write explicit line continuation. So you see it is not either one or the other.

In fact the only case where there is a need for a terminator/separator, is when it would make sense to start a new instruction on the new line. In the example you provided, the + symbol cannot start a statement, so there is no ambiguity.
Conscience is the debugger of the mind

munair

  • Hero Member
  • *****
  • Posts: 696
  • keep it simple
    • SharpBASIC
Re: Making the semicolon useless
« Reply #91 on: April 07, 2020, 02:57:25 pm »
In fact the only case where there is a need for a terminator/separator, is when it would make sense to start a new instruction on the new line. In the example you provided, the + symbol cannot start a statement, so there is no ambiguity.
Maybe not in this particular example, but that would require the programmer to know where and where not to break a statement to the next line. What if you break it before an identifier? It would add a LOT of complexity to the compiler to distinguish between an assignment, procedure call or line continuation.

Language design is all about consistency, or at least it should be, and explicit statement termination was introduced to provide just that - to leave no ambiguous situations as to when a statement ends, apart from the fact that it greatly improves readability, which, as I said earlier is often a big issue with high level languages.

Also think about language extension. Without clarity and consistency, compiler engineers quickly would need to resort to patch work making maintenance/extension more and more difficult over time. Having everything in place consistently leaves little to no room for ambiguity making a compiler so much more simple to maintain and extend. Believe me, I know this from first hand experience.

Also, do not mix the statement separation/termination issue with other building blocks like Pascal's IF statement, which I agree, isn't the best or easiest to understand.

In any case, redesigning FPC to make the statement separator optional simply is NOT doable nor preferable. I can say this with confidence even without having looked one single time at the FPC source code. It would require a complete redesign of the parser which in turn would greatly affect the parts of the compiler that are directly parser-dependent to the extent that the compiler will break completely. Trust me, you'd be better off designing a new language.

guest65405

  • Guest
Re: Making the semicolon useless
« Reply #92 on: April 07, 2020, 07:07:15 pm »
I have several likenesses in behaviour and account data, some of which I have commented on here. If you insist, I'll pass it all on to my co moderators for judgement in a query about account deletion.

Or you can just own up to it, and get a fair last chance, just because I also overstepped a bit in a bad mood.

Despite you deleted your account the last time when I pmed you with warnings, I should still have gone that way instead of posting in the thread out of the blue. Mea culpa, and a last chance for you if you are honest about it.

I liked Pascal but I don't like Lazarus. Indeed I don't like the RAD philosophy.

I want to make Pascal a normal language like C++, do not stuck with any frameworks and free to do everything as a general purpose language.

Did anyone ever think about using Pascal to code GTK+ alongside with Glade and not through the LCL abstraction?

This is my idea.

Creating the IUP binding is part of my project to de-Lazarus Free Pascal. But after I actually use it on my projects I found it opened another can of worms. In anyway, when we do GUI we need a designer. I don't have knowledge do build a designer. And the way IUP was designed it needs to paired with languages like LED or Lua to be useful. So what is the point at all? All the efforts I made go to nothing.

It's circular reasoning. We need a designer to do GUI efficiently with IUP without relying on languages like LED or Lua. But we don't have it and have to write one. In other to write one we need to do GUI in IUP since we avoided the LCL. So on and so on.

I give it up sir. You are free to think about me the way you like. I will delete my account, you don't have to care about me anymore.

I hope someday someone capable will pick up my idea and actually turn it to real. A Pascal without Lazarus. But I think it will never happen.

p/s: Believe it or not, I'm not the troll you mentioned.

howardpc

  • Hero Member
  • *****
  • Posts: 3446
Re: Making the semicolon useless
« Reply #93 on: April 07, 2020, 07:39:53 pm »
I hope someday someone capable will pick up my idea and actually turn it to real. A Pascal without Lazarus. But I think it will never happen.
It is certainly not likely to be pursued with any enthusiasm on a forum which is dedicated in both name and purpose to Lazarus.

Fred vS

  • Hero Member
  • *****
  • Posts: 1760
    • StrumPract is the musicians best friend
Re: Making the semicolon useless
« Reply #94 on: April 07, 2020, 07:54:28 pm »
Quote
I hope someday someone capable will pick up my idea and actually turn it to real. A Pascal without Lazarus. But I think it will never happen.

MSEide, MaXimus from fpGUI, ideU?

https://wiki.freepascal.org/IDE
« Last Edit: April 07, 2020, 07:56:22 pm by Fred vS »
I use Lazarus 2.0.6 32/64 and FPC 3.2.0 32/64 on Debian 10.2 64 bit, 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

marcov

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 8458
  • FPC developer.
Re: Making the semicolon useless
« Reply #95 on: April 07, 2020, 08:05:53 pm »
Quote
Did anyone ever think about using Pascal to code GTK+ alongside with Glade and not through the LCL abstraction?

Yes.

p.s. fpgtk before fpgui, even.
« Last Edit: April 07, 2020, 08:08:51 pm by marcov »

Fred vS

  • Hero Member
  • *****
  • Posts: 1760
    • StrumPract is the musicians best friend
Re: Making the semicolon useless
« Reply #96 on: April 07, 2020, 08:12:09 pm »
Quote
p.s. fpgtk before fpgui, even.

Hu, fpgtk, what is that, no mention in wiki?

https://wiki.freepascal.org/IDE
I use Lazarus 2.0.6 32/64 and FPC 3.2.0 32/64 on Debian 10.2 64 bit, 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

440bx

  • Hero Member
  • *****
  • Posts: 1876
Re: Making the semicolon useless
« Reply #97 on: April 07, 2020, 08:27:05 pm »
A Pascal without Lazarus. But I think it will never happen.
It has already happened.  FPC doesn't need Lazarus in any way to produce an object file.

I don't use Lazarus as a RAD.  I only use it as a front end to GDB.  I use FPC as a replacement for C.

I agree with Munair.  The semicolon isn't an "ornament" in the language grammar.  Without it, the parser would have to work a lot harder to figure out where a new statement begins and, trivial syntax errors could make that determination ambiguous in many cases, leading to poor error messages (and quite likely several tokens _after_ the error actually is.) Most compilers aren't particularly good about emitting precise, genuinely informative error messages, an "improvement" that makes emitting good error messages harder or impossible for the compiler simply is no improvement at all.

Can the semicolon be removed from Pascal ?... probably, after all, PL/I allows the programmer to define variables named the same as "reserved" words.  If that can be parsed,  Pascal without semicolons can likely be parsed too but, the question that comes to mind is, why would anyone invest the time and aggravation in producing such a parser ?... a small semicolon for man, a giant leap for Computer Science ?... I don't think that one will go down in history.
 



FPC v3.0.4 and Lazarus 1.8.2 on Windows 7 64bit.

marcov

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 8458
  • FPC developer.
Re: Making the semicolon useless
« Reply #98 on: April 07, 2020, 09:07:52 pm »
Quote
p.s. fpgtk before fpgui, even.

Hu, fpgtk, what is that, no mention in wiki?

https://wiki.freepascal.org/IDE

Sebastian worked on a parallel IDE called Kassandra with the KCL as library around 2000. However that was massive and progressed slowly, so he created a OOP wrapper for GTK (1.2 on *nix/ 1.3 on Windows)called FPGTK library to do his current projects.

One or two years later, he got more windows customers, and created FPGUI library  to have one library for both gtk and windows (GDI) for immediate use.

The first editor/ide for fpdoc documentation files was called fpde and was a fpgtk application.

 

Fred vS

  • Hero Member
  • *****
  • Posts: 1760
    • StrumPract is the musicians best friend
Re: Making the semicolon useless
« Reply #99 on: April 07, 2020, 09:18:25 pm »
Ha, it was also Sebastian that did it!

Wow, very creative man.

I did find a program file here:

fpc/trunk/packages/fpgtk/src/pgtk/pgtk.pp

Is it still maintained and compilable (first shot was not out-of-the-box)?

I use Lazarus 2.0.6 32/64 and FPC 3.2.0 32/64 on Debian 10.2 64 bit, 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

marcov

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 8458
  • FPC developer.
Re: Making the semicolon useless
« Reply #100 on: April 07, 2020, 10:04:56 pm »
fpc/trunk/packages/fpgtk/src/pgtk/pgtk.pp

Is it still maintained and compilable (first shot was not out-of-the-box)?

As far as I can see I migrated it from the old base/extra structure to the unified packages/ in 2008, and nothing has been done with it since. The mutations seem to be only makefile regenerations and spelling fixes in comments and license tests.

And, you'd have to dig out gtk1 somewhere.

Fred vS

  • Hero Member
  • *****
  • Posts: 1760
    • StrumPract is the musicians best friend
Re: Making the semicolon useless
« Reply #101 on: April 07, 2020, 10:06:55 pm »
About pgtk.pp, OK, I get it, adding some -Fu../* did the trick.

Hum, it is a command-line that gives without parameter as result:

Quote
Give 2 filenames :
   First the object description file
   Second the Pascal unit filename

Hum, ok, must jump into it to catch the thing.

Anyway, thanks Marco for the discover.

And sorry to monopolize with something out of the topic.

Fre;D
« Last Edit: April 07, 2020, 10:09:32 pm by Fred vS »
I use Lazarus 2.0.6 32/64 and FPC 3.2.0 32/64 on Debian 10.2 64 bit, 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

munair

  • Hero Member
  • *****
  • Posts: 696
  • keep it simple
    • SharpBASIC
Re: Making the semicolon useless
« Reply #102 on: April 12, 2020, 07:55:45 am »
All of the things you mentioned, do not work. Some abandoned. Some hopelessly outdated. These broken things can't be used to hide the fact we are so dependent on the LCL.

I have done my work to do GUI without the LCL. Thanks to the Windows API and a wrapper library I ported from C. But I still have to use Lazarus as IDE because there is no real alternative.
Don't be surprised. Nowadays GUIs are huge and it is a lot of work to just keep things up-to-date. Windows is just one part. GTK development is going so fast, it is hard to keep up, especially by people who do not get paid for it.

munair

  • Hero Member
  • *****
  • Posts: 696
  • keep it simple
    • SharpBASIC
Re: Making the semicolon useless
« Reply #103 on: April 14, 2020, 09:27:58 am »
Back to the topic, another perhaps not so trivial reason not to abandon the semicolon is the ability to arrange code in a way that makes it easier to read/understand. This can be the case with more complex expressions that otherwise would have to be crammed on a single line.

Here is a somewhat exaggerated example from the project I'm working on, but it illustrates the issue very well:
Code: Text  [Select][+][-]
  1. func leapy(y:int):bool
  2. do
  3.   leapy =
  4.     (
  5.       y % 4 = 0
  6.     and
  7.       y % 100 <> 0
  8.     )
  9.     or
  10.     (
  11.       y % 400 = 0
  12.     ); // semicolons are a blessing
  13. end;

It computes leap years according to the Gregorian calendar and it is one of my favorites to test expression parsing. Each part of the expression can be comfortably commented on. With more complex programs this is non-trivial. It definitely makes them easier to read and maintain, even after several years when the function of certain parts have become less obvious  ;)

440bx

  • Hero Member
  • *****
  • Posts: 1876
Re: Making the semicolon useless
« Reply #104 on: April 14, 2020, 11:43:09 am »
@Munair,

An unrelated question, I see your function uses the function name to assign it a return value.  Do you plan to implement something like "result" in FPC in your compiler to optionally use that instead of the function's name ?
FPC v3.0.4 and Lazarus 1.8.2 on Windows 7 64bit.

 

TinyPortal © 2005-2018