Recent

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

guest58172

  • Guest
Re: Making the semicolon useless
« Reply #45 on: April 03, 2020, 07:43:02 pm »
you have
Code: bnf  [Select][+][-]
  1. IfStatement   ::= 'if' Condition ThenStatement ElseStatement?
  2. ThenStatement ::= 'then' Statement
  3. ElseStatement ::= 'else' Statement


That's perfectly LL(1), in no way more than one lookup is necessary.
I am not sure I understand where you define the semicolon here.

Indeed TIL that in pascal the semicolon is not part of the Statement, unlike C.
So the simple change I thinked of would not work.

So the semicolon is introduced by this rule https://www.freepascal.org/docs-html/current/ref/refsu55.html#x161-18300013.2.1 ?
Mmmh I don't like this.


guest58172

  • Guest
Re: Making the semicolon useless
« Reply #46 on: April 03, 2020, 07:45:16 pm »
It introduces complexilty because of the dangling else .... That is not complex, isn't it... Try to adapt a Pascal grammar...<SIGH  >:D>

The explanation for the confusion is that I didn't know that the semicolon is not part of the Statement rule. I was actually thinking in C.

circular

  • Hero Member
  • *****
  • Posts: 4181
    • Personal webpage
Re: Making the semicolon useless
« Reply #47 on: April 03, 2020, 11:41:37 pm »
So I would like to retract my earlier advise to try modify fcl-passrc, but advise you to whip up some relevant examples (also think about errorhandling, so also wrong/non compilable tests!) and try to use some parser generator tool to get some grammar that is roughly working on these examples to flesh out the details and get a starting point.
I understand the grammar approach, though as I explained before, I guess I would rather have a token approach. It is quite simple to have a preprocessor that adds semicolon. That could leave the compiler untouched.
Conscience is the debugger of the mind

marcov

  • Administrator
  • Hero Member
  • *
  • Posts: 11351
  • FPC developer.
Re: Making the semicolon useless
« Reply #48 on: April 04, 2020, 12:00:28 am »
So I would like to retract my earlier advise to try modify fcl-passrc, but advise you to whip up some relevant examples (also think about errorhandling, so also wrong/non compilable tests!) and try to use some parser generator tool to get some grammar that is roughly working on these examples to flesh out the details and get a starting point.
I understand the grammar approach, though as I explained before, I guess I would rather have a token approach. It is quite simple to have a preprocessor that adds semicolon. That could leave the compiler untouched.

As said: Then better have an IDE tool to occasionally try to fix. Advantage: runs on less code at once so does have to be as perfect. And you don't need to carve up your buildsystem to pull al your source through the preprocessor before calling the real compiler.

440bx

  • Hero Member
  • *****
  • Posts: 3921
Re: Making the semicolon useless
« Reply #49 on: April 04, 2020, 12:19:09 am »
Aside from any feasibility and compatibility considerations, I don't think that getting rid of the semicolon is really worth much effort.  Is there a semicolon phobia I don't know about... a "semiphobia" ? ;)

Thinking more about it, I think phobias should be semicolon separated too;  Just practicing my ataxophobia;  (the combination of tax phobia and; poorly formatted Pascal code phobia;)

(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: 4181
    • Personal webpage
Re: Making the semicolon useless
« Reply #50 on: April 04, 2020, 10:39:28 am »
 :D

I don't know of any phobia of that kind ; though I suppose it is possible ;

@marcov: Indeed an IDE tool could the the instant conversion between the view and the code file. Though I don't know how to do such a tool.
Conscience is the debugger of the mind

lainz

  • Hero Member
  • *****
  • Posts: 4449
    • https://lainz.github.io/
Re: Making the semicolon useless
« Reply #51 on: April 04, 2020, 02:36:37 pm »
Languages changes, evolves or die.

And most mutations die.
That escalated quite quickly. This is just a discussion, relax.  8-)

Sorry, I only wanted to say in a language evolution, not species. I was tired so because that I wrote the 'die' part, not very well planned  :)

I mean, I never used semicolons to write Spanish or English, but I know these was often used in the past. Modern texts does't use them or most people don't know how to use them.

marcov

  • Administrator
  • Hero Member
  • *
  • Posts: 11351
  • FPC developer.
Re: Making the semicolon useless
« Reply #52 on: April 04, 2020, 02:44:23 pm »
:D

I don't know of any phobia of that kind ; though I suppose it is possible ;

@marcov: Indeed an IDE tool could the the instant conversion between the view and the code file. Though I don't know how to do such a tool.

Maybe we are thinking about different things. I'm not talking about a new "language" or anything, just an edit menu option in lazarus to check a block of selected code and add missing semicolons. Just like e.g. tabs-to-spaces, which implementation could be followed.



marcov

  • Administrator
  • Hero Member
  • *
  • Posts: 11351
  • FPC developer.
Re: Making the semicolon useless
« Reply #53 on: April 04, 2020, 02:47:07 pm »
I mean, I never used semicolons to write Spanish or English, but I know these was often used in the past. Modern texts does't use them or most people don't know how to use them.

True, and the main reason for that is that natural languages are hopelessly context sensitive and ambiguous and thus not machine parseable, which is the whole reason that programming languages exist :-)

Being easily parseable is the raison d'être of programming languages.

del

  • Sr. Member
  • ****
  • Posts: 258
Re: Making the semicolon useless
« Reply #54 on: April 04, 2020, 03:21:56 pm »
This is what happens when the first language people learn is Python. It's ugly. Trust me.

lainz

  • Hero Member
  • *****
  • Posts: 4449
    • https://lainz.github.io/
Re: Making the semicolon useless
« Reply #55 on: April 04, 2020, 04:28:07 pm »
This is what happens when the first language people learn is Python. It's ugly. Trust me.

I do not agree. One of the fist languages of mine is Pascal. I don't use python.

Seems that it happens when I learned Kotlin, that's more evolved language currently in existence.

MarkMLl

  • Hero Member
  • *****
  • Posts: 6646
Re: Making the semicolon useless
« Reply #56 on: April 04, 2020, 04:31:45 pm »
This is what happens when the first language people learn is Python. It's ugly. Trust me.

I wouldn't touch it with a barge pole, and I don't trust you. Sorry :-)

MarkMLl
MT+86 & Turbo Pascal v1 on CCP/M-86, multitasking with LAN & graphics in 128Kb.
Pet hate: people who boast about the size and sophistication of their computer.
GitHub repositories: https://github.com/MarkMLl?tab=repositories

Otto

  • Full Member
  • ***
  • Posts: 226
Re: Making the semicolon useless
« Reply #57 on: April 04, 2020, 07:33:18 pm »
Hello everyone.

I would like to say that the question posed by circular is interesting, I believe that any proposal that aims to discuss a possible greater spread of Lazarus/FPC is to be considered. Simplifying code writing might be useful for this purpose.

However, I do not agree with the specific proposal: in my opinion the use of the symbol ";" in pascal is of fundamental importance, more for the programmer than for the compiler.
Many users have already reported a good reason why keeping a visible separator is of paramount importance.
I would like to add that for work, sometimes, I have to correct errors in codes written in VB.net by others. Very often I have to rewrite a lot of the code in C.C. and then convert it back to VB.net;  because, often, the causes are induced by errors of logic induced precisely by the permissiveness typical of the language VB.net. What I want to say is that if some programmers know that it is possible to use a system apparently "simplified" can make a bad use of it, in case of problems it will then be more complex to identify the real cause.

Surely it would be possible, more or less easily, to enter a mode that would allow the elimination of the ";"; but I think if you really had this need it would be better to use an external preprocessor functionality. In this case, the product code could be compiled normally without having to make any changes to the FPC compiler.

Otto.
Kind regards.

circular

  • Hero Member
  • *****
  • Posts: 4181
    • Personal webpage
Re: Making the semicolon useless
« Reply #58 on: April 04, 2020, 10:28:55 pm »
Maybe we are thinking about different things. I'm not talking about a new "language" or anything, just an edit menu option in lazarus to check a block of selected code and add missing semicolons. Just like e.g. tabs-to-spaces, which implementation could be followed.
Ah ok no I was thinking of making an editor where the semicolon do not appear, yet they are saved in the file for the compiler.
Conscience is the debugger of the mind

Thaddy

  • Hero Member
  • *****
  • Posts: 14158
  • Probably until I exterminate Putin.
Re: Making the semicolon useless
« Reply #59 on: April 05, 2020, 11:30:22 am »
But our Pascal doesn't use ';' as an end of statement but a separator between statements. It's the problem.
It separates code blocks It is no problem at all....
Specialize a type, not a var.

 

TinyPortal © 2005-2018