Good evening Ed,
I have. However, Algol68 is constrained in that it cannot pass functions
out from inner scope in the manner that I want to play with.
Just to give a simple example and this is a slightly modified version of
the original quote from the first book that took me down this path
"Polymorphic Programming Languages - Design and Implementation"
let nextCounter := {
let hiddenCounter := 0
-> function() {
hiddenCounter := hiddenCounter + 1
-> hiddenCounter
}
}
In this case the variable nextCounter holds a value that is of type
Function and is called by nextCounter() to give the next value required.
The variable hiddenCounter is in the outer scope of the function value
that is currently assigned to nextCounter but cannot be seen by any
observer looking at or using the function. In effect, the variable is in
scope for the function but is inaccessible to anything at the level of
nextCounter. This value can then be sent to scoping levels further out
without anyone being the wiser over how or what variables are being used.
The above definition could be just as easily written as
let nextCounter: Function := {
let hiddenCounter:Integer := 0
-> function() {
hiddenCounter := hiddenCounter + 1
-> hiddenCounter
}
}
This in effect means that there are no name space collisions, no
keywords that indicate that a variable name is private, public or
protected. Just the Algol scope rules.
Though for the purposes of what I am trying to achieve, environments and
symbols are also values and this would allow such things as
let enumerate := lazy function (typename:Symbol idlist:Block) {
def env = free.part (),
ntb = new.Type (typename), // type & key
type = ntb [1],
tkey = ntb [2],
esize = make.key (tkey 1) // ordinals
for i to size.of (eval.in env idlist) do {
let this.val := make (type esize i),
this.sym := idlist [i]
rebind (env this.sym this.val)
}
-> ntb
}
which could be called
let Colour, ColourIndex := enumerate (Colour [red, green, blue]}
where red, green and blue would each be associated with a value (each
different) whose type would now be in the variable Colour.
This is why I was asking the original question about PEGs in the first
place. To provide a means of creating the appropriate means of
expressing some of the above while also allowing an extension when
creating new operators or even keywords within the language.
All of this necessitates that most things be found within the heap and
not an an execution stack. I don't know of any Algol68 version that
allows the above.
Kernel is another Lispish language that heads towards what I am aiming
for but it deliberately excludes environments from being searched for
symbols by code, even though it quite happily passes environments around
and treats them as values.
I like Icon/Unicon and would like to start the process with it as the
base and work up.
Edward A. Feustel wrote:
> Bruce & Breeanna Rennie wrote:
>> To all,
>>
>> My ultimate goal is develop a compiler for a simple Algol - based
>> language where most things in the language can be considered values
>> and where each value is very strongly typed. Included in the kinds of
>> types of values are Types etc which don't get much of a look in when
>> being passed around the system.
>>
>>
>>
> Bruce,
> Have you considered simply using Algol68? There are a number of
> compilers out there.
> Ed
--
regards
Bruce Rennie
(God's Own Country Downunder)
Warragul. Victoria.
Australia.
-------------------------------------------------------------------------
This SF.net email is sponsored by the 2008 JavaOne(SM) Conference
Don't miss this year's exciting event. There's still time to save $100.
Use priority code J8TL2D2.
http://ad.doubleclick.net/clk;198757673;13503038;p?http://java.sun.com/javaone
_______________________________________________
Unicon-group mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/unicon-group