Wow, already a groupie! :-P
Seriously though, I'd love some feedback. I just started though, so I'll wait until I get a working compiler and a specific standards document before I go to to SourceForge.
It will be compatible with ISO 7185, but not with Delphi, ISO 10206, or OOE. [edit]Although compatability units are a definite thought for the future.[/edit]
I plan to have some cool stuff though.
- most of EP's
import and
export powers (sans the circular crap)
- schemata extended to parameterize on types
- operator definition and overloading, a la PXSC (though I'm still not too sure on that
priority keyword, but ATM I don't know how else to express the start of an operator declaration section, as the word
operator is taken to declare a routine)
-
record,
class, and
interface (but
not EP's stupid, redundant, anti-pascalian
view). I'm still not sure what to do with the
object keyword, but it might be dumped entirely in favor of
class. I'm also still not sure I want to use the EP
restricted keyword --it also seems redundant.
-
threadvar and
critical section blocks
- exception handling of both software and hardware (OS) signals (which are actually very consistent across hardware)
- improved
try block structure
-
interrupt routines for low-level programming
-
assembler routines and
asm blocks. More notes on this follow.
- both simple and smart pointer types. More notes on this follow.
-
currency,
complex, and
bignum types (that is, as built-in types)
var c: complex = 3r+2i;
- dynamic
array types (homogeneous data)
- dynamic
list types (heterogeneous data)
- default parameters, variable argument lists, and maybe even named- and implicit- argument passing
- all structured types have automatic reference counting (including
widestrings and objects)
-
sets of any named-type (homogeneous data), in addition to the optimized ordinal-type sets
-
case statements that work on
strings
-
propertys that are usable like any true variable (brought to you by...)
- enhanced heap management. Again, see notes below about smart pointers
-
foreach in and
for in sequence loops (see below)
- I'm still considering adding a step value to
for x := statements. That is one thing I really missed from BASIC.
- constant initializers for anything, including in sub-blocks
- variant parts in classes (easy! so why not?)
- numeric constants in any radix in 2..36, expressed in a number of ways (conventional-style, EP-style, and my own style:
%1010
=
2#1010
=
1010b
)
- cleaned-up syntax
- improved heap management (over 'new', 'dispose' and 'getmem', 'freemem')
- automatic type introspection (without the need for RTTI)
- some relaxations on type compatabilities?
- true unicode support. [added by edit]
Hmm. I think that's it for now.
Notes:
Assembly
I'm thinking of providing a custom assembly language (in addition to the machine's native asm) so that modules can be pre-compiled and usable on
any os --that is, without having to distribute source code. This is different than DLLs, which are OS-dependant, and which are
not able to be statically linked into the resulting EXE, and which do not provide packed interface data. (I don't want to mess around with native DLL formats. [edit] That is, beyond the ability to compile and use them normally. ;-) [/edit])
Pointers and Heap Management
All computer hardware gives you the power to handle memory in a very convenient way --but usually only the OS makes use of these abilities (and old systems like MS DOS don't even do that).
This means smart pointers, scope-based garbage collection, and the aforementioned power to treat properties as if they were actual variables. The overhead to do these kinds of things are acceptable (relatively small, even), but completely avoidable if desired.
As in Delphi, all objects are allocated on the heap. I include records, strings, bignums, etc. and add automatic reference counting (for garbage-collection).
Use of smart pointers automatically handles the reference counting, and they codify something that is only nebulously taught about Delphi: references. (Hence, in my Pascal a
reference is a smart
pointer.)
Again, all this stuff can be avoided -- you are not forced to use references with objects.
Example:
1 2 3
|
type
stupid: ^integer; // this is a standard pointer
smart: integer^; // this is a reference
|
Foreach
For-statements are expanded to take a sequence. The two look identical but the semantics are different:
1 2 3 4 5 6 7 8
|
var
x, y: integer;
begin
for x, y in [1, 2, 3], [4, 5, 6] do
write( '(', x, ',', y, ') ' );
foreach x, y in [1, 2, 3], [4, 5, 6] do
write( '(', x, ',', y, ') ' )
end
|
The
for loop takes the sequences linearly --as if concatenating them-- and produces
The
foreach loop takes the sequences in parallel --as if zipping them-- and produces
This is just a little
Tclism I like.
Libraries
Only a very few routines will be defined by the language. Everything else will be a library. I have in mind SDL and a cross-platform windowed library, but that is to be fleshed-out
after I get this compiling console stuff. :-)
Well, I'm hungry, so let me know what you think and give any suggestions for improvement,etc.