Recent

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

440bx

  • Hero Member
  • *****
  • Posts: 3944
Re: defining a subset of pascal
« Reply #15 on: October 17, 2020, 12:06:07 pm »
but he did an amazing work and i have his book.
Is the book you are referring to "Per Brinch Hansen on Pascal Compilers" ? (Pascal-) if it is, you can use the same architecture he used for Pascal- to implement a variant of SuperPascal.  Since SuperPascal is public domain, just borrowing Pascal-'s architecture (not the code) should be ok. 

it is one of the most interesting works on compiler construction.
I agree.  IMO, his implementations are by far the cleanest.

it is interesting that my copy, which is used, has notes made in pencil, someone tried to translate the code to modula-2.
I translated/ported Pascal- to Turbo Pascal and then Delphi 2 long ago.

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.
I believe it is possible if you use the SuperPascal code which is public domain and only use the architecture of Pascal-.  IMO, that's the ideal implementation of a back end to produce highly optimized code.

but thanks for reminding me!
My pleasure.
(FPC v3.0.4 and Lazarus 1.8.2) or (FPC v3.2.2 and Lazarus v3.2) on Windows 7 SP1 64bit.

PascalDragon

  • Hero Member
  • *****
  • Posts: 5446
  • Compiler Developer
Re: defining a subset of pascal
« Reply #16 on: October 17, 2020, 12:17:00 pm »
i think freepascal devs or community have to try to define a new, completely new language subset, which compiler would check with some switch.

No. Neither we devs nor the community has to try anything here. We're already hard at work catching up with Delphi's features which is a very much community driven demand plus the support of the two Pascal standards for the sake of completeness and bragging points. Adding an additional, new, more restricted language dialect would result in unnecessary work and complication and the target audience would probably be even smaller than those that currently use mode ISO and look forward to a fully supported mode ExtPas.

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.

No. We don't agree on that. Even among us devs there is the division between those that defend the ObjFPC dialect (which is at least a bit more strict than mode Delphi) and those that would like to see it gone (though that will never happen due to our stance on backwards compatibility).

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.

It would nevertheless complicate the parser even more, because each added modeswitch requires checking after all.

BeniBela

  • Hero Member
  • *****
  • Posts: 905
    • homepage
Re: defining a subset of pascal
« Reply #17 on: October 17, 2020, 01:24:08 pm »
Less features do not make it safer

We need more features to make it safer. Smart pointers or a borrow checker or a garbage collector to get memory safety. Better checking for uninitialized variables, so uninitialized variables become a compile time error. Inline for variable declarations, so the loop variable is not uninitialized after the for loop. A contract verifier like SPARK or like Wuffs that proves there are  no range check errors or integer overflows when the code compiles.   Perhaps one could change Wuffs to have a Pascal syntax and generate Pascal code.

lproven

  • New member
  • *
  • Posts: 9
Re: defining a subset of pascal
« Reply #18 on: October 18, 2020, 01:09:01 pm »
Hmm. Apparently the Preview button does not work? This kind of thing is why I loathe web fora. :-(
 
@inky:

Quote
i am founder of vishap oberon compiler and i hang out in #oberon room on irc.freenode.net.


I don't normally do IRC except for work, but I will have a look.

Quote

right now not, though because my country is in war and i have no mood.

Um. Which country is that? I cannot view your profile -- it says I do not have permission.

Quote
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

I think that compiles to C, right?

Quote
if you'd like to use oberon as an operating system/editor/environment

I am interested in a **native** port of Oberon to the Pi, and I hope later to other ARM SBCs. I am not really interested in anything running on top of Linux, because part of my objective is to demonstrate that something far smaller and simpler than Linux is viable.

lproven

  • New member
  • *
  • Posts: 9
Re: defining a subset of pascal
« Reply #19 on: October 18, 2020, 01:13:40 pm »

@inky
Quote
i thought he needs an oberon compiler or environment for raspberry pi/linux

No. I have seen several.

Quote
but i see now he may be thinks of booting a version natively.

Yes. The single remaining lecturer at ETH has said that they do have an experimental version booting internally to the university, built from the work of many students, but that he is too busy to share it externally. :-(

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

I realise that.

But for me the interest and significance of Oberon is as a minimal OS environment. Running it on top of a bloated C-based OS fails to communicate this.

It is not that I dislike Linux -- I work in the Linux industry for a Linux vendor -- but I am interested in exploring alternatives to C-based OSes and the entire C-based ecosystem. That is (part of) my interest in Pascal. 

PascalDragon

  • Hero Member
  • *****
  • Posts: 5446
  • Compiler Developer
Re: defining a subset of pascal
« Reply #20 on: October 18, 2020, 01:18:34 pm »
Hmm. Apparently the Preview button does not work? This kind of thing is why I loathe web fora. :-(

It does. It's just that if you scrolled down the preview will be inserted above and the browser won't scroll up, but you can see at the scrollbar on the right that something happend. If you now scroll up then you'll see the preview (I've just tested this to confirm).

MarkMLl

  • Hero Member
  • *****
  • Posts: 6676
Re: defining a subset of pascal
« Reply #21 on: October 18, 2020, 01:27:49 pm »
Less features do not make it safer

We need more features to make it safer.

That sort of thing only works if the older feature can be completely replaced by the newer one, and in a way that users don't notice (i.e. the old syntax remains available as a shim over the new implementation, and there is no performance change).

For example, why does a modern Pascal have to have both strings and objects, when in principle strings could be reimplemented as objects?

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

MarkMLl

  • Hero Member
  • *****
  • Posts: 6676
Re: defining a subset of pascal
« Reply #22 on: October 18, 2020, 01:35:21 pm »
Quote
if you'd like to use oberon as an operating system/editor/environment

I am interested in a **native** port of Oberon to the Pi, and I hope later to other ARM SBCs. I am not really interested in anything running on top of Linux, because part of my objective is to demonstrate that something far smaller and simpler than Linux is viable.

OK, so let's get something straight here although I must say that you're not expressing it very well (I have the advantage here of our copious "private correspondence" as they say in academia).

What you're trying to do I think- and please correct me if I'm putting words in your mouth- is port the Oberon operating system to an ARM target such as the RPi. That's not "native" so much as bare metal... and I'd suggest that it would still be fair to have what used to be called a virtual machine but today would probably have to be called an interpreter executing bytecodes at the lowest level (prior art: Burroughs MCP, UCSD Pascal).

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

MarkMLl

  • Hero Member
  • *****
  • Posts: 6676
Re: defining a subset of pascal
« Reply #23 on: October 18, 2020, 01:48:06 pm »
But for me the interest and significance of Oberon is as a minimal OS environment. Running it on top of a bloated C-based OS fails to communicate this.

As you know I can sympathise with that, but the difficult thing is looking at the entire set of OSes (i.e. every OS that has ever been written, extant or otherwise) and working out what features are absolutely essential.

A good place to start would be looking at what absolutely had to go into microkernel based OSes: MINIX, L4, Redox or for that matter https://ultibo.org/ My own conviction is that the OS itself at the very lowest level needs memory management, context switching and a locking mechanism for interprocess communications and not much else: things like process scheduling algorithms can be external.

It's also necessary at this stage to look at some of the "howlers" that have gone into modern OSes. However I won't continue since I'm not sure that we should be hijacking this thread for extended discussion.
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

marcov

  • Administrator
  • Hero Member
  • *
  • Posts: 11382
  • FPC developer.
Re: defining a subset of pascal
« Reply #24 on: October 18, 2020, 03:06:59 pm »
For example, why does a modern Pascal have to have both strings and objects, when in principle strings could be reimplemented as objects?

Can they? Since then strings would be a purely library concept, the lifetime would be very generalized and optimal.  How would you implement copy on write?

Afaik even java and C# have special internal handling in the GC for strings to avoid their immutability not leading to a memory bloat.
 

MarkMLl

  • Hero Member
  • *****
  • Posts: 6676
Re: defining a subset of pascal
« Reply #25 on: October 18, 2020, 04:00:06 pm »
Can they? Since then strings would be a purely library concept, the lifetime would be very generalized and optimal.  How would you implement copy on write?

If you can identify shortcomings in the object model then perhaps they should be fixed in the object model.

Quote
Afaik even java and C# have special internal handling in the GC for strings to avoid their immutability not leading to a memory bloat.

Which TBH is something that bothers me enormously: if a "fundamental" high-level-language facility can't be implemented without lots of low-level tricks then perhaps it should be reconsidered.

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

marcov

  • Administrator
  • Hero Member
  • *
  • Posts: 11382
  • FPC developer.
Re: defining a subset of pascal
« Reply #26 on: October 18, 2020, 04:58:39 pm »
Can they? Since then strings would be a purely library concept, the lifetime would be very generalized and optimal.  How would you implement copy on write?

If you can identify shortcomings in the object model then perhaps they should be fixed in the object model.

You an also reverse that. We were talking about strings, not objects. If they are really the same, it should reveal no new shortcomings in the object model. If new shortcomings exist, maybe the assumption simply doesn't hold true.

Quote
Quote
Afaik even java and C# have special internal handling in the GC for strings to avoid their immutability not leading to a memory bloat.

Which TBH is something that bothers me enormously: if a "fundamental" high-level-language facility can't be implemented without lots of low-level tricks then perhaps it should be reconsidered.

I don't understand what your conclusion with this paragraph is. Not to have strings? Not to map them to objects?

ASBzone

  • Hero Member
  • *****
  • Posts: 678
  • Automation leads to relaxation...
    • Free Console Utilities for Windows (and a few for Linux) from BrainWaveCC
Re: defining a subset of pascal
« Reply #27 on: October 19, 2020, 10:49:00 pm »
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.
So true!  :)
-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)

dtoffe

  • Jr. Member
  • **
  • Posts: 55
Re: defining a subset of pascal
« Reply #28 on: October 21, 2020, 03:16:09 am »
    The fpc team has a clearly stated commitment to support standards and backwards compatibility, and supporting six dialects seems complex enough already for a compiler.
    Perhaps you can start a project based on other available projects, for example this "fairly complete" compiler has been discussed some time ago in this forum:

https://github.com/75557032/llvmpas

https://forum.lazarus.freepascal.org/index.php/topic,43007.0.html

    And there is also this one which lacks code generation:

https://github.com/wanderlan/llvm-pascal

    There are also other fairly complete Modula 2/3 and Oberon compilers written in languages other than Object Pascal, it depends on how much adventurous you feel about taming a dragon...

Daniel

 

TinyPortal © 2005-2018