MogunWARNING: INFO ON THIS PAGE IS EXTREMLY OUTDATED. LEFT FOR HISTORICAL PURPOSES ONLYMogun is Factor-inspired and Factor-hosted language and is currently in early design stage. Its primary target is low-level speed-critical tasks, which you do not normally write on Factor itself (cell tags, GC, etc). Core of its design is programmer-friendly static typing with transparent and precise control over any compiler optimizations. Possibly, it's going to be LLVM-backended. Basic Principles (UNDER CONSTRUCTION)Local stack shufflingOnly local stack shuffling primitive is : drop ( >X ) ; : dup ( <X X ) ; : swap ( <Y X >Y ) ; : dip -- ( >X QUOT ) call X ; : keep -- ( X QUOT ) call X ; : 2drop drop drop ; : 2dip -- swap [ dip ] dip ; : bi -- [ keep ] dip call ; : bi* -- [ dip ] dip call ; : bi@ -- dup bi* ; In combinators defititions you can see Type-systemIn Mogun any element on stack belongs to one of statically-distinguished class hierarhies. Inside each hierarhy classes can be statically or dynamically converted to each other. Classes can have additional slots with optimization-assisting values, avaliable at compile-time. Class from one hierarhy can simulate behaviour of other hierarhy, and can be used in its place. CLASS: integer { min -inf } { max +inf } ;
CLASS: uint ? integer { min 0 } ;
CLASS: sgn ;
CLASS: positive < sgn ;
CLASS: zero < sgn ;
CLASS: negative < sgn ;
MIMIC: integer sgn
CLASS: fixed bitcount ;
CLASS: ufixed = fixed ;
CLASS: sfixed = fixed ;
MIMIC: ufixed uint
MIMIC: sfixed integerIn this example you can see three class hierarhies: Quotation semanticsMogun quotation can be more complex then Factor one. It provides branching based on type-checking and in-place tail-cut recursion. For example, lets look at Mogun implementation of Factor : times -- swap :integer
[ :positive -- [ [ call ] keep ] [ 1- ] bi* rec
| :zero 2drop
] call ;Core loop of this word is divided by
Both branches start with type-checking -
If quotation have more then one branch, in type checking part you can use only type-checking and stack-shuffling words. When At the end of the first branch you can see This revision created on Mon, 13 Jul 2009 12:38:05 by Keyholder |
|||||
|
All content is © 2008-2010 by its respective authors. By adding content to this wiki, you agree to release it under the BSD license. |
|||||