Recent

Author Topic: A modest proposal in response to those who want "curly brackets"  (Read 13128 times)

MarkMLl

  • Hero Member
  • *****
  • Posts: 6676
A modest proposal in response to those who want "curly brackets"
« on: February 01, 2021, 10:16:43 am »
It seems that hardly a month can pass before somebody, almost always a newcomer to the forum and frequently a newcomer to Pascal, makes the earnest suggestion that the language would be improved if instead of having begin and end tokens Pascal adopted braces ("curly brackets") to delimit a block.

If I comment to this I usually point out that as well as being a long-accepted comment marker in Pascal, the closely-related language Modula-2 uses braces to delimit sets, and since much of the syntax of Object Pascal (i.e. the post Jensen & Wirth dialect) resembles Modula-2 it would make sense to reserve the option to use Modula-2 style sets etc. at some point in the future.

A literal set delimited by braces is unordered, i.e. the two sets {'a', 'b', 'c'} and {'a', 'c', 'b'} are indistinguishable from the POV of the language. Taking that into consideration, using braces to delimit a code block would appear to be particularly inappropriate, since the whole point of a code block is that the statements it encloses are executed in an ordered fashion.

I would propose instead that rather than using braces { } to delimit a code block, it would be more appropriate to use (square) brackets [ ]. I believe that there are a number of plausible arguments in this suggestion's favour:

* Among ALGOL-derived languages, square brackets are universally understood to represent array indexes which are by their nature ordered.

* Square brackets were adopted as block delimiters by Smalltalk in 1970. As such this usage predates C (1972) and is roughly contemporaneous with B and BCPL.

* I believe that this suggestion would be compatible with Pascal's existing syntax.

If this suggestion were adopted, and if a later variant of Pascal adopted the Modula-2 convention of using braces { } to identify an (unordered) literal set, it might also be possible to use braces to identify a group of statements that could be parallelised or at least reordered subject to dataflow dependencies by the compiler.

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

440bx

  • Hero Member
  • *****
  • Posts: 3944
Re: A modest proposal in response to those who want "curly brackets"
« Reply #1 on: February 01, 2021, 11:23:12 am »
I find the fixation some people have with curly brackets a bit peculiar but, I suggest a compromise.  Those who want curly brackets should purchase a hair curler and curl their hair before writing code.  That way they get their "curl fix" and might be more inclined to leave the Pascal language alone.

If someone could get donald trump to sell hair curlers, we might get the "curly boys".

Seriously, if someone loves curly brackets so much, they should program in C, all the curly brackets they can type. 

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

Zvoni

  • Hero Member
  • *****
  • Posts: 2317
Re: A modest proposal in response to those who want "curly brackets"
« Reply #2 on: February 01, 2021, 11:51:59 am »
If someone could get donald trump to sell hair curlers, we might get the "curly boys".
"CURL FIRST!"

Nevermind, that it would be a "fake implementation" like everything else in Donnie's Life.....
One System to rule them all, One Code to find them,
One IDE to bring them all, and to the Framework bind them,
in the Land of Redmond, where the Windows lie
---------------------------------------------------------------------
Code is like a joke: If you have to explain it, it's bad

marcov

  • Administrator
  • Hero Member
  • *
  • Posts: 11383
  • FPC developer.
Re: A modest proposal in response to those who want "curly brackets"
« Reply #3 on: February 01, 2021, 11:59:32 am »
It seems that hardly a month can pass before somebody, almost always a newcomer to the forum and frequently a newcomer to Pascal, makes the earnest suggestion that the language would be improved if instead of having begin and end tokens Pascal adopted braces ("curly brackets") to delimit a block.

Yes.

Quote
since much of the syntax of Object Pascal (i.e. the post Jensen & Wirth dialect) resembles Modula-2 it would make sense to reserve the option to use Modula-2 style sets etc. at some point in the future.

It is already reserved for comments.

PascalDragon

  • Hero Member
  • *****
  • Posts: 5446
  • Compiler Developer
Re: A modest proposal in response to those who want "curly brackets"
« Reply #4 on: February 01, 2021, 01:10:35 pm »
I would propose instead that rather than using braces { } to delimit a code block, it would be more appropriate to use (square) brackets [ ]. I believe that there are a number of plausible arguments in this suggestion's favour:

You do notice that by suggesting an alternate, you're essentially starting the absolute same discussion that's involved with the usual suggestion just with a bit of different flavoring?

If this suggestion were adopted, and if a later variant of Pascal adopted the Modula-2 convention of using braces { } to identify an (unordered) literal set, it might also be possible to use braces to identify a group of statements that could be parallelised or at least reordered subject to dataflow dependencies by the compiler.

There won't be any kind of braces as block markers, cause this is Pascal which uses words instead of symbols for such things.

Bart

  • Hero Member
  • *****
  • Posts: 5275
    • Bart en Mariska's Webstek
Re: A modest proposal in response to those who want "curly brackets"
« Reply #5 on: February 01, 2021, 01:15:06 pm »
There won't be any kind of braces as block markers, cause this is Pascal which uses words instead of symbols for such things.

Yes, Pascal is a verbose language by design.
If you dislike verbosity, there are plenty of alternatives available, some of them are also very suitable for NARGs.

Bart

ASBzone

  • Hero Member
  • *****
  • Posts: 678
  • Automation leads to relaxation...
    • Free Console Utilities for Windows (and a few for Linux) from BrainWaveCC
Re: A modest proposal in response to those who want "curly brackets"
« Reply #6 on: February 01, 2021, 01:27:34 pm »
Seriously, if someone loves curly brackets so much, they should program in C, all the curly brackets they can type.

Or GoLang...
-ASB: https://www.BrainWaveCC.com/

Lazarus v2.2.7-ada7a90186 / FPC v3.2.3-706-gaadb53e72c
(Windows 64-bit install w/Win32 and Linux/Arm cross-compiles via FpcUpDeluxe on both instances)

My Systems: Windows 10/11 Pro x64 (Current)

trev

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 2020
  • Former Delphi 1-7, 10.2 user
Re: A modest proposal in response to those who want "curly brackets"
« Reply #7 on: February 01, 2021, 01:29:37 pm »
For the reverse obsession, when I was involved in the development of the Opus CBCS (BBS) in the early 1980s, the original author Wynn Wagner III (RIP) wrote C like Pascal - no curly braces to be seen, but begin and end everywhere - see, for example zreceive.c :)

Leledumbo

  • Hero Member
  • *****
  • Posts: 8746
  • Programming + Glam Metal + Tae Kwon Do = Me
Re: A modest proposal in response to those who want "curly brackets"
« Reply #8 on: February 03, 2021, 08:02:17 pm »
Or GoLang...
That one refuses to be called a C family member despite taking the basic block structure from it just because it's also inspired by Oberon (consequently, Pascal) for declaration sectioning, declaration order (identifier first, type later) and type bound procedures, perhaps also import aliasing.

CM630

  • Hero Member
  • *****
  • Posts: 1081
  • Не съм сигурен, че те разбирам.
    • http://sourceforge.net/u/cm630/profile/
Re: A modest proposal in response to those who want "curly brackets"
« Reply #9 on: February 03, 2021, 08:18:38 pm »
The Arduino language (some kind of C I think) uses {} instead of Begin/ End. I still cannot get used to that.
Лазар 3,2 32 bit (sometimes 64 bit); FPC3,2,2; rev: Lazarus_3_0 on Win10 64bit.

MarkMLl

  • Hero Member
  • *****
  • Posts: 6676
Re: A modest proposal in response to those who want "curly brackets"
« Reply #10 on: February 03, 2021, 08:44:27 pm »
The Arduino language (some kind of C I think) uses {} instead of Begin/ End. I still cannot get used to that.

It's C++, with a little bit of extra preprocessing.

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

skalogryz

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 2770
    • havefunsoft.com
Re: A modest proposal in response to those who want "curly brackets"
« Reply #11 on: February 03, 2021, 09:32:20 pm »
To be honest, I don't see a reason why not to have some sort of "Cascal" project.
Just a C-like syntax notation (language, if you want) that would be translated directly into Pascal.
Naturally RTL and all language types would be Pascal based (strings, dynamic arrays, managed types... etc)

Maybe go a bit further than C-family and allow things like this:
Code: C  [Select][+][-]
  1. void SomeFunc(int a, b, c)

Again: this should be aside project (a translator), not a native compiler support.

Some syntax would need to be introduced to provide support for Pascal units.
But they can also be borrowed from c-like non-OOP languages, i.e. D.

In some sense, this is what Apple done with Swift-language.
« Last Edit: February 03, 2021, 09:44:10 pm by skalogryz »

MarkMLl

  • Hero Member
  • *****
  • Posts: 6676
Re: A modest proposal in response to those who want "curly brackets"
« Reply #12 on: February 03, 2021, 10:38:45 pm »
To be honest, I don't see a reason why not to have some sort of "Cascal" project.

Leaving aside for a moment the "reservations" of the community, I think the major argument against that is the extent to which type checking etc. would have to be relaxed... do we really want to be party to that? C is really not a well-thought-out language, it started off with essentially nothing which could not be implemented using assembler macros (adding a modicum of block structure to assembler code was a very popular project in the 80s, hence I suspect Trev's comment about somebody who used begin and end with C).

C++ has attempted to tighten things up and has then layered a lot of complexity on top, which is basically "putting lipstick on a pig". Few people who- IMO- really know what they're doing attempt to defend it: "Within C++, there is a much smaller and cleaner language struggling to get out." (Stroustrup).

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

skalogryz

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 2770
    • havefunsoft.com
Re: A modest proposal in response to those who want "curly brackets"
« Reply #13 on: February 03, 2021, 10:48:03 pm »
I think the major argument against that is the extent to which type checking etc. would have to be relaxed...
why relax any pascal restriction?
(except for the mandatory "var" section, which comes next to curly braces?)

People who is asking for curlies, don't have a type checking on their mind.

Even the operators priority could stay in a pascal way. (yes, people will complain that copy-pasted C code doesn't compile in Cascal)
« Last Edit: February 03, 2021, 10:49:44 pm by skalogryz »

dpremus

  • New Member
  • *
  • Posts: 32
Re: A modest proposal in response to those who want "curly brackets"
« Reply #14 on: February 03, 2021, 11:54:09 pm »
When I was started learning Pascal (Turbo Pascal 3.0 for DOS) there is no curly brackets on my keyboard.

In that time curly brackets was replaced with local characters for my country so "{"  was replaced with "Š"
and "}" was replaced with "Đ".    :)

So in that time I was used  "(*"   and  "*)" instead curly brackets. and "(." ".)" instead "["  "]"
But  "(*"   "*)" are still great for debugging, for example when you need to comment some code that already have comments with curly brackets.

Code: Pascal  [Select][+][-]
  1. (*
  2.  
  3. { frist multiline
  4.   comment }
  5. procedure test1;
  6. begin
  7. end;
  8.  
  9. { second multiline
  10.   comment }
  11. procedure test2;
  12. begin
  13. end;
  14.  
  15. *)
  16.  


But only thing that I would like to see in Pascal, was multi line string. That will be great for SQL and HTML template.



 

TinyPortal © 2005-2018