• Welcome to Theos PowerBasic Museum 2017.

The R$ Project.: Prototype for a high level RPN Language

Started by Charles Pegge, September 18, 2007, 12:02:43 AM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

Charles Pegge


This version of R$ will be withdrawn  shortly (as of 29 Sept 2007)
Please see the R$ sticky topic for the latest version. The one included here is a very early prototype.



This is in the form of a console-based program to trial high-level code using Postfix or Reverse Polish Notation.

One of principle innovations used here is to combine the RPN notation with Markup notation to support Object-Oriented and Declarative styles of coding, as well as Procedural.

I hasten to add that this is very much a prototype, and does not even attempt to be efficient, while the focus is on getting the language right.

The questions I want to explore are:

Is it easy to write?
Is the code easy to debug and modify?
Is the code easy to read?

Does it afford any advantage over Infix (conventional) notation from a programmers point of view?


The source code, written in Freebasic will can be used in both MSWindows and Linux. An EXE file is included in the ZIP below, along with a series of simple test sequences which excercise most of the commands and functions incorporated so far. These are
deployed in the 'main.prg' file.

Further development:

By introducing types, structures and function declares it will be possible to interface directly with DLLs for the Windows API etc. This is a distinct lower-level layer on the language to deal with, but I think the notation will be able to accommodate it quite well, without getting too messy.

Petr Schreiber

Charles,

thanks a lot for this preview.
It is still quite cryptic, but nice thing to experiment with :)


Thanks,
Petr
AMD Sempron 3400+ | 1GB RAM @ 533MHz | GeForce 6200 / GeForce 9500GT | 32bit Windows XP SP3

psch.thinbasic.com

Charles Pegge

#2
Yes this code feels totally different, I think it requires a different part of the brain to comprehend it. With infix notation, we have to do quite a lot of subconscious decyphering because of the punctuation and various groupings and reversals, but with this stuff, you always go from left to right except when doing a 'repeat' loop.

Keeping track of things on the stack is an additional task, but by making use of brackets for block scoping, it is easy to disallocate chunks of stuff, and leave the stack in its prior state without needing to know how many variables had been accumulated there.

Another reason for appearing cryptic is that pointy brackets are reserved exclusively for markup, and comparators have to be represented by words, for which I use the upper case:

Update: now using lowercase for these - makes them easier to use:

  < lt
  > gt
<= le
>= ge
<> ne
== eq

There are other possibilities too:

  true
  false
  null
  void
  is
be


Kent Sarikaya

Charles I am chomping at the bit to play with $ and R$, but I am trying to clear of my mind of programming as I looked at so many languages lately that I am lost... so I am cleansing my mind to get into powerBasic with a clear mind. SO I will have to put off playing with it, but wanted to say I appreciate your creativity in putting these out and in what seems like an amazingly short period of time.

Charles Pegge


I know just how you feel  Kent. There are so many creatures in the software jungle to deal with. Introducing new ones does not always enhance the programming experience.

To cope with language differences, I have drastically simplified my coding style in recent months, to keep the syntax and programming logic as clean as possible. I find it makes a huge difference, using a small subset of the available constructs.

That still leaves the problem of coping with all these libraries of course :)