Talk:Pastel (programming language)

Page contents not supported in other languages.
From Wikipedia, the free encyclopedia

Pastel syntax[edit]

There's detail from Jeff Broughton at https://forum.lazarus.freepascal.org/index.php/topic,64224.0.html:

>> Constant expressions

const
   <name> = <expr>;    (* expr can contain, constants, other named constants and operators *)
   (* likewise, constant-value expressions could be used in type declarations, and other places where simple constants were required *)


>> Variable initialization

var
   <name> : <type> = <expr>. (* equivalent to an assignment at the start of the block *)


>>  Loop-exit form:

loop. (* loop forever, until exit condition is true *)
   ….
exit if <expr>; (* multiple allowed *)
  ….
end;


>> Additional control constructs

let <name> = <expr> do <stmt>;   (* assign the value to the variable, and execute the statement *)
    (* the variable is known only within the scope of the statement *)


>> Condition boolean operations

orif / andif  (* analogous to || and && *)


>> Return statement

return <expr>;  (* from a function *)
or
return;  (* in a procedure *)


>> Set iteration

for <name> in <set expr> do <stmt> ;   (* perform statement with name bound to values in the set *)


>> Additional parameter passing modes

In a procedure or function declaration:

procedure xxx (<ptype> <name> : <type>; … )

<ptype> could be
       var — by reference
       <empty> — by value
       in — by value
       out — copy out on return
       inout — by value on input and copy out on return


>> Module definition

module <name> ;  (* at the beginning of a file defines a module *)

use <name> ;  (* in another file, incorporates the definitions from another module *)

I believe that you had to use x.y in a referencing module.   I don’t believe that it did an “import *”.


>> Improved type definition

I believe that you could do things like

type
  <name> :   0..<expr>  (* where expr was actually a variable expression, useful with parameters and fields, especially arrays *)


>> Parametric types

We were able to define a record that was partly self defining.    Examples:

type
    x = record
         y: integer
         z: array [0..y] of integer;
         end

   a = record
         b:  0..4
         case b of
             0: (d, e, f:…);
             1: (g, h, i: …);

These were intended to be used with pointers to records to describe variable operation system structures.
   
 I forget if we could specified the values in a new, so that the record was of the minimum lenghth.


>> Explicit packing and allocation control

I vaguely recall that you could add “packed <bitsize>” to individual field definitions.


>> Exceptions

I forget how these worked.

I think it's worth having this in the record, but I'm reluctant to try to work it into the article only to have it ripped out by a more-established editor on the grounds that the references are inadequate or that the author was too closely associated with the project. MarkMLl (talk) 09:52, 1 January 2024 (UTC)[reply]