Language "Heaven"
# components -> { :red -> 5, :green -> 6, :blue -> 5 }
structure Bitfield( width, storage_type : type@uint! )
bits := storage_type.bits
@storage : storage_type = 0
def mask_of( index: uint )
assert( index < bits )
2 ** (bits - index - 1)
end
def mask_of( selection: range(uint) )
assert( selection.within? [0..bits) )
bmask := mask_of( selection.begin )
emask := mask_of( selection.end )
end
def operator[]( index: uint )
@storage & mask_of(index)
end
def operator[]=( index: uint, value: bool )
if ( value )
@storage &= ~mask_of(index)
else
@storage |= mask_of(index)
end
end
def operator[]( selection: range(uint) )
selection.clamp
case index
when int
when range
end
end
end
structure Packed( *components )
@@width := componets.values.sum
@data : Bitfield(@@width) = 0
components.each_index do |i,component,cwidth|
shift := components(i..).values.sum
def #{component}(); @data[shift..shift+cwidth) << (8-shift); end
def #{component}=( value ); @data[shift..shift+cwidth) = ( value >> (8-shift) ); end
end
end
Pakced # -> type factory ?
ColorType := Packed( :red->5, :green->6, :blue->5 ) # -> type
Previous Work
A pragmatic language for the future (GDNet Thread)
Outstanding Issues
Range comparisons
Comparison Chaining?
1 <= 2 <= 3 <= 4
operator<= returns rhs if lhs<=rhs, otherwise nil ?
ComparisonResult -> bool && ComparisonResult <= Numeric ?
Comparitive Operator?
1 <=> 2 — :lessthan (ordered), :equal, :inequal (unordered) :greaterthan (ordered)?
(1 <= 2) == (1 <=> 2 != :greaterthan) ?
Range Syntax
[begin..end) [begin..end] (begin..end] (begin..end) ?
begin..end begin…end ?
Globals and dual-stage eval
dirs = Dir[ "fnord/*" ] —- is this relative to the CWD during compile or the CWD during run-eval() init?
Overloading & Multiple Dispatch
Call syntax:
f( a, b, c ) - best-match lookup
f( a:type, b:type, c:type ) - coerceion?
f( a:~type, b:~type, c:~type ) —- base lookup?
Ambiguities:
Stage 1 (compile) eval: Error
Stage 2 (runtime) eval: Diagnose potential type "valleys"? Major reliance on assert()ions?
Pre/post-conditions, assertions
class Array
operator[]( unsigned index )
precondition index < self.size
return …
end
end
Current Work
Literals
0x0123456789ABCDEF[.FFFF] -- hexadecimal literal
01234567[.7777] -- octal literal
10100011101[.1111]b -- binary literal
1234567890[.0000] -- Decimal Literal
:abdef1234 -- Symbol (deferred on-access lookup)
abdef1234 -- Identifier (immediate current-scope lookup)
"fnord!!:\"aasdf" -- String (localizeable)
???? -- String (unlocalizeable)
Scopes
- Build-Time [Global]
- Build-Time [Unit]
- Function
- Class





