Recent

Author Topic: defining a subset of pascal  (Read 4651 times)

inky

  • New Member
  • *
  • Posts: 41
    • github
defining a subset of pascal
« on: October 16, 2020, 11:13:37 am »
i am disturbed by the amount of features pascal accumulated over years.
today was searching on the net and found my old reddit post: https://www.reddit.com/r/ada/comments/5bvyey/language_complexity/

i do like pascal, and especially i like freepascal compiler implementation. i like, for example, that it is not part of gcc, but independently developed, has own, very good memory manager, and by default generates kernel calls avoiding libc usage.

on the other hand i mostly program in oberon. because of its, i would say, modernistic and minimalistic design and concentration on safety. i know it has a small and divided community, almost no libraries, in other words small number of speakers. but i tell it to make clear why am i writing this.

i think freepascal devs or community have to try to define a new, completely new language subset, which compiler would check with some switch.
i know we have iso pascal, but that's not enough.
for example, i would suggest that this new subset, which should, i believe concentrate on safety, would not allow more than one exit from a function procedure.

here cbfsoftware describes how oberon enforces many of misra rules: https://web.archive.org/web/20130703231115/http://www.ocp.inf.ethz.ch/forum/index.php/topic,609.0.html

so what do you think?
i understand that we have a lot of legacy code (python decided to not support legacy code but create a better 3.x branch) and need to have some kind of delphi compatibility.
also, LCL is, as far as i know, written without any restrictions on features used.
but i think that fpc community and/or devs are the people who can agree on some minimalistic and safe features for clean design of new pascal language subset.

even ada did similar thing by introducing spark though it is a bit different story.

the good thing it won't require much changes, or introduction of new features. it would only require a limitation of feature usage by a commandline switch.
« Last Edit: October 16, 2020, 11:17:41 am by inky »

Thaddy

  • Hero Member
  • *****
  • Posts: 14358
  • Sensorship about opinions does not belong here.
Re: defining a subset of pascal
« Reply #1 on: October 16, 2020, 11:44:54 am »
We already have the two ISO modes (7185 and 10206), which are quite restrictive and concise. Why add another one?
Anyway, some of the forum members already have written things like TinyPascal and family.
7185 is from 1983 and revised in 1990. Seems limiting enough... :P

So defining a subset of modern  pascal can be done: use the ISO 7185 as a template and start from there. It does not support objects nor classes...
« Last Edit: October 16, 2020, 11:54:12 am by Thaddy »
Object Pascal programmers should get rid of their "component fetish" especially with the non-visuals.

MarkMLl

  • Hero Member
  • *****
  • Posts: 6682
Re: defining a subset of pascal
« Reply #2 on: October 16, 2020, 11:59:47 am »
I think that (i) Liam Proven joined a couple of days ago and you should be talking to each other due to your Oberon interest and (ii) that what you might be looking for is "Spayed Pascal" i.e. with the "dangerous" bits chopped out.

Frankly I am an admirer of the Modula-3 way of doing things, i.e. with specific modules annotated as containing unsafe code which should be maintained only by an experienced programmer.

Tangentially, and with apologies for departing from OP's topic as raised, I also feel that the ongoing Oracle vs Google case (heard by the US Supreme Court a few days ago) should be taken as a wakeup call: it's far easier to separate a descriptive interface (not eligible for copyright protection) and an implementation (eligible for copyright and possibly patent protection) if they're in separate files, and the Modula-3 approach demonstrates that that can also have project management advantages.

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

lproven

  • New member
  • *
  • Posts: 9
Re: defining a subset of pascal
« Reply #3 on: October 16, 2020, 01:27:33 pm »
I think that (i) Liam Proven joined a couple of days ago and you should be talking to each other due to your Oberon interest

Oh, er, hello. That'll be me, then.

Yes, I am interested in Oberon, although I have not learned it as of yet. The reason I joined the fora here is that I am trying to resurrect my extremely rusty Pascal skills from the 1980s.

@inky -- Oberon is alive and relatively well. The "ETH Oberon and related systems" mailing list <oberon@lists.inf.ethz.ch> is relatively active. I am also in a Telegram chat channel on Oberon and A2 and it's busy, but it's all in Russian. That seems to be where the language and OS are most appreciated these days.

I am interested to see if I can learn enough to attempt a port to the Raspberry Pi -- I think it could be an ideal hobbyist/teaching environment, especially on the low-price single-core RasPis (the Zero, Zero W etc.) where Linux does not work well.

MarkMLl

  • Hero Member
  • *****
  • Posts: 6682
Re: defining a subset of pascal
« Reply #4 on: October 16, 2020, 01:56:34 pm »
I am interested to see if I can learn enough to attempt a port to the Raspberry Pi -- I think it could be an ideal hobbyist/teaching environment, especially on the low-price single-core RasPis (the Zero, Zero W etc.) where Linux does not work well.

Hold on, I think you've dropped a sentence. Port what in this context?

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

inky

  • New Member
  • *
  • Posts: 41
    • github
Re: defining a subset of pascal
« Reply #5 on: October 16, 2020, 10:12:54 pm »
I think that (i) Liam Proven joined a couple of days ago and you should be talking to each other due to your Oberon interest

Oh, er, hello. That'll be me, then.

Yes, I am interested in Oberon, although I have not learned it as of yet. The reason I joined the fora here is that I am trying to resurrect my extremely rusty Pascal skills from the 1980s.

@inky -- Oberon is alive and relatively well. The "ETH Oberon and related systems" mailing list <oberon@lists.inf.ethz.ch> is relatively active. I am also in a Telegram chat channel on Oberon and A2 and it's busy, but it's all in Russian. That seems to be where the language and OS are most appreciated these days.

I am interested to see if I can learn enough to attempt a port to the Raspberry Pi -- I think it could be an ideal hobbyist/teaching environment, especially on the low-price single-core RasPis (the Zero, Zero W etc.) where Linux does not work well.

hello!
i am founder of vishap oberon compiler and i hang out in #oberon room on irc.freenode.net.
right now not, though because my country is in war and i have no mood.
the room is not busy anyway, but there you can find my bot - vocbot - which is written in oberon from scratch - first i implemented unix sockets wrapper, then python like easy to use internet library, then irc module, and then the bot logic. https://github.com/norayr/irc_bot. it uses packages as git submodules - Internet, irc, lists and time packages from my
other repositories.

i don't use telegram.
glad to know there is active russian community though.

for raspberry pi, if you're interested in just commandline compiler, i would of course suggest to use ours - vishap oberon compiler. https://github.com/vishaps/voc

if you'd like to use oberon as an operating system/editor/environment - you have two options:

0. josef temple's ofront. it is an amazing tool and became more amazing recently, in 2016 he added dynamic module loading. so it works like a real oberon system though when you compile your module, it actually gets translated to c, then linked as shared object, and loaded, when needed.
but you need 32bit linux for this.

1. oberon linux revival by peter mathias. amazing project, actually even two projects. he has oberon s3 for arm, and he has latest po13 oberon with oberon-07 compiler for arm.
i would suggest running more classical version, it has more software and is more fun. though it is also only 32bit, you can use it on pure 64bit linux system.
because it uses x protocol to draw (no linkind to xlib necessary) and it uses kernel calls (like fpc) directly without glibc linking. so it only requires kernel and x (or framebuffer) to run.

marcov

  • Administrator
  • Hero Member
  • *
  • Posts: 11444
  • FPC developer.
Re: defining a subset of pascal
« Reply #6 on: October 17, 2020, 12:34:34 am »
(added later as clarifier: I'm refering to Misra rules below)
How would this work in FPC's case? I think those rules goes for the entire system, so a limited subset calling into a RTL in a not limited  context would violate them?

Anyway, I played with the idea of starting a M2 platform at some time in the past and asked some questions, the stages of the current compiler's scanner-parser are somewhat interwoven and optimized for speed.  This makes alternate, pluggable frontends a bit hard, as few parts of the compiler are modularly isolated because of practical (speed) reasons.

Another possible problem would be having to surpress Pascal's type promotion type systems.
« Last Edit: October 17, 2020, 08:25:34 pm by marcov »

inky

  • New Member
  • *
  • Posts: 41
    • github
Re: defining a subset of pascal
« Reply #7 on: October 17, 2020, 12:56:00 am »
I think that (i) Liam Proven joined a couple of days ago and you should be talking to each other due to your Oberon interest and (ii) that what you might be looking for is "Spayed Pascal" i.e. with the "dangerous" bits chopped out.

thank you. but i did not find "spayed pascal" on the net.
also i would like to have a fpc based solution because i like the compiler.

inky

  • New Member
  • *
  • Posts: 41
    • github
Re: defining a subset of pascal
« Reply #8 on: October 17, 2020, 12:59:51 am »
We already have the two ISO modes (7185 and 10206), which are quite restrictive and concise. Why add another one?
Anyway, some of the forum members already have written things like TinyPascal and family.
7185 is from 1983 and revised in 1990. Seems limiting enough... :P

So defining a subset of modern  pascal can be done: use the ISO 7185 as a template and start from there. It does not support objects nor classes...

thank you very much, i looked at both standards, and extended pascal seems attractive.
it's a pity it has no oop. also some things are not intuitive, like usage of Succ and Pred instead of Inc and Dec.

i think may be ideally it should be modern pascal like dialect, but with minimal features, i. e. only one type of string, etc.

but yes, for non-oop work i think i can consider extended pascal.

440bx

  • Hero Member
  • *****
  • Posts: 4014
Re: defining a subset of pascal
« Reply #9 on: October 17, 2020, 05:56:57 am »
it's a pity it has no oop. also some things are not intuitive, like usage of Succ and Pred instead of Inc and Dec.

i think may be ideally it should be modern pascal like dialect, but with minimal features, i. e. only one type of string, etc.

but yes, for non-oop work i think i can consider extended pascal.
Just in case you might be interested, there is Per Brinch Hansen's SuperPascal which is both a subset and a superset of Pascal.  It eliminates unsafe features and adds coroutines.  One of its interesting features is that the compiler can determine at compile time potential synchronization problems among coroutines.

If interested you can find a good description in Wikipedia at the link https://en.wikipedia.org/wiki/SuperPascal

The bottom of the page has links to the original version which was for a Sun Sparc and an FPC (mode iso) port.  Per Brinch Hansen placed the source code in the public domain but retains copyrights on the compiler manuals which are in Tex (or one of its variants).  It's a very interesting compiler and, it is very well written (recursive descent, hand written by PBH) and easy to understand, the documentation is easy to read and also easy to understand.  (Note: it's not a "real" compiler, it produces bytecode which is interpreted. Also while the manuals are good, they are not a tutorial on how to write a compiler.)

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

dbannon

  • Hero Member
  • *****
  • Posts: 2791
    • tomboy-ng, a rewrite of the classic Tomboy
Re: defining a subset of pascal
« Reply #10 on: October 17, 2020, 07:19:42 am »
Maybe all you need is to define a particular style guide ?  A set of rules, we don't exit a method early, we don't use classes, we use only short strings and so on ?

The trouble with asking for a minimal Pascal is just about every one who agrees a minimal pascal is a good idea will require a slightly different subset. So, its very unlikely you could get your subset enforced by the compiler.

But defining your own style guide is entirely within your reach. And up to you to apply to your programming.

Where you would run into trouble is if you want to use something like LCL. Internally it uses the things you may not approve of and quite often those internals are exposed and you are expected to use them. But, honestly, you cannot reasonably expect something like LCL to be rewritten to suite either a new compile language OR style. It just won't happen.

So, you need to provide all your own libraries. Hmm....

Davo
Lazarus 3, Linux (and reluctantly Win10/11, OSX Monterey)
My Project - https://github.com/tomboy-notes/tomboy-ng and my github - https://github.com/davidbannon

MarkMLl

  • Hero Member
  • *****
  • Posts: 6682
Re: defining a subset of pascal
« Reply #11 on: October 17, 2020, 09:18:47 am »
I think that (i) Liam Proven joined a couple of days ago and you should be talking to each other due to your Oberon interest and (ii) that what you might be looking for is "Spayed Pascal" i.e. with the "dangerous" bits chopped out.

thank you. but i did not find "spayed pascal" on the net.
also i would like to have a fpc based solution because i like the compiler.

Looks like it needs to be mis-spelled as "spade pascal" to get any useful hits.

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

inky

  • New Member
  • *
  • Posts: 41
    • github
Re: defining a subset of pascal
« Reply #12 on: October 17, 2020, 10:56:41 am »
it's a pity it has no oop. also some things are not intuitive, like usage of Succ and Pred instead of Inc and Dec.

i think may be ideally it should be modern pascal like dialect, but with minimal features, i. e. only one type of string, etc.

but yes, for non-oop work i think i can consider extended pascal.
Just in case you might be interested, there is Per Brinch Hansen's SuperPascal which is both a subset and a superset of Pascal.  It eliminates unsafe features and adds coroutines.  One of its interesting features is that the compiler can determine at compile time potential synchronization problems among coroutines.


indeed, i did not consider it, because i was thinking of limiting a subset from the fpc supported features.

but he did an amazing work and i have his book. it is one of the most interesting works on compiler construction.
it is interesting that my copy, which is used, has notes made in pencil, someone tried to translate the code to modula-2.
it's a pity it won't be possible to use his code for the frontend and add a custom backend and release it under a free license.
but thanks for reminding me!

inky

  • New Member
  • *
  • Posts: 41
    • github
Re: defining a subset of pascal
« Reply #13 on: October 17, 2020, 10:59:13 am »
Maybe all you need is to define a particular style guide ?  A set of rules, we don't exit a method early, we don't use classes, we use only short strings and so on ?

The trouble with asking for a minimal Pascal is just about every one who agrees a minimal pascal is a good idea will require a slightly different subset. So, its very unlikely you could get your subset enforced by the compiler.

But defining your own style guide is entirely within your reach. And up to you to apply to your programming.

Where you would run into trouble is if you want to use something like LCL. Internally it uses the things you may not approve of and quite often those internals are exposed and you are expected to use them. But, honestly, you cannot reasonably expect something like LCL to be rewritten to suite either a new compile language OR style. It just won't happen.

So, you need to provide all your own libraries. Hmm....

Davo

yes, style guide and the checker would be something like SPARK i mentioned.
they did not write a separate ADA compiler but decided to use a separate tool that limits the feature usage, if i can simplify like that.

yes, i don't expect LCL or any other existing fpc code to be rewritten.
i even can link to existing libraries, i anyway do now link to C code when writing in Oberon. at least i can know i like that my own code uses that limited minimalistic subset.

inky

  • New Member
  • *
  • Posts: 41
    • github
Re: defining a subset of pascal
« Reply #14 on: October 17, 2020, 11:02:58 am »
I am interested to see if I can learn enough to attempt a port to the Raspberry Pi -- I think it could be an ideal hobbyist/teaching environment, especially on the low-price single-core RasPis (the Zero, Zero W etc.) where Linux does not work well.

Hold on, I think you've dropped a sentence. Port what in this context?

MarkMLl

may be i misunderstood him.
i thought he needs an oberon compiler or environment for raspberry pi/linux, but i see now he may be thinks of booting a version natively.

that would be much harder, at least would require writing driver and replacing many low level modules that do linux system calls.

 

TinyPortal © 2005-2018