Lively Kernel canvas
ContextJSSyntaxExperiments(LayerDefintion)40true
Version0:ImperativeLayerDefinition20
createLayer("LayerName");layerClass(LayerName,MyClass,{foo:function($proceed,value){return$proceed(value)*2}})layerObject(LayerName,MyClass,{//...})})1614
Aproblemwithbothaproachesisthatpartiallayeredclassdefintionscannotbeinteractivlyexecuted(withouttoolsupport).171
cop.layer("LayerName",{MyClass:{foo:function($proceed,value){return$proceed(value)*2}},//PROBLEM:doesnotwork,becauseobjects//cannotbeusedaskeysindictionariesmyObject:{//...}})1615
cop.layer("LayerName").layer([MyClass,{foo:function($proceed,value){return$proceed(value)*2}}],[myObject,{//..}]})1610
Version4A:OOVersion,LayerdefintionistheresponsibilityofLayerObject201
Version5:usingarraystodeclareparitialclassandobjectbehaviordefintions202
cop.layer("HelloLayer").layer(MyClass,{foo:function($proceed,value){return$proceed(value)*2}},myObject,{//..}})1611
Version720
Version1:ImplicitLayerDefinition(Analogtomoduledefinition)201
Version2:ExplicitLayerDefinition20
20null
cop.createLayer("LayerName");cop.layerClass(LayerName,MyClass,{foo:function($proceed,value){return$proceed(value)*2}})cop.layerObject(LayerName,MyClass,{//...})})1614
Version0.1:ImperativeLayerDefinition(withNamespacePrefix)201
Version3:analogtoclassdefinitions20
Version4B:OOVersion20
cop.layer("LayerName").layerClass(MyClass,{foo:function($proceed,value){return$proceed(value)*2}})cop.layer("LayerName").layerObject(myObject,{//..})165
LayerName=newLayer("LayerName")LayerName.layerClass(MyClass,{foo:function($proceed,value){return$proceed(value)*2}})LayerName.layerObject(myObject,{//..})1610
Version4C:OOVersion20
cop.layer("LayerName")LayerName.layerClass(MyClass,{foo:function($proceed,value){return$proceed(value)*2}})LayerName.layerObject(myObject,{//..})1610
Version6:getridof"["and"]"20
Problem:distinctionbetween,layeringaclassandlayeringtheclassobjectislost172
cop.layer("LayerName",function(){cop.layerClass(MyClass,{foo:function($proceed,value){return$proceed(value)*2}})cop.layerObject(myObject,{//...})})1613
UseingFunctionsasScope20
UseingFunctionsasScope20
cop.layer("LayerName").layerClass(MyClass,{foo:function($proceed,value){return$proceed(value)*2}}).layerObject(myObject,{//..})16
Version4D:OOCascadingVersion20
cop.layer("LayerName").beGlobal().layerClass(MyClass,{foo:function($proceed,value){return$proceed(value)*2}}).layerObject(myObject,{//..})166
Version4E:OOCascadingVersion/WithEnable20
cop.layer("LayerName").beGlobal().layerClass(MyClass,{foo:function($proceed,value){return$proceed(value)*2}}).layerObject(myObject,{//..})169
Version4E:OOCascadingVersion/WithIdentation20
cop.create("UndoLayer",function(){this.refineClass(TextMorph,{onKeyDown:function($proceed,evt){//....return$proceed(evt)}});this.refineObject(myObject,{//...});})166
cop.layer("LayerName",function(layer){layer.layerClass(MyClass,{foo:function($proceed,value){return$proceed(value)*2}})layer.layerObject(myObject,{//...})})1610
null0.005437620338475331null
Version2B:BetterNames20
null0.12918533522020836null
function(){...}providesarealscope-allowsforotherimperativemessagesendsto"this"layerexample:this.activateGlobally()or:beGlobal()-allowsforaccessingandsharingencapsulatedstateinsidetheclosure174
null-0.5929960628178198null
cop.create("UndoLayer",function(){varhistory=[];this.refineClass(TextMorph,{onKeyDown:function($proceed,evt){//....history.push({key:evt})return$proceed(evt)}});})166
cop.create("UndoLayer",function(){varlayer=this;layer.history=[];layer.refineClass(TextMorph,{onKeyDown:function($proceed,evt){//....layer.history.push({key:evt})return$proceed(evt)}});})166
null0.7026254248056145null
storingsharedstateinthelayerasaproperty1
HowdifficultisittoparsefortheTools?17
Wikicontroltruetrue
Version2C:Explicit20
cop.create("UndoLayer",function(layer){UndoLayer.refineClass(TextMorph,{onKeyDown:function($proceed,evt){//....return$proceed(evt)}});UndoLayer.refineObject(myObject,{//...});})1516
cop.create("UndoLayer",function(layer){layer.refineClass(TextMorph,{onKeyDown:function($proceed,evt){//....return$proceed(evt)}});layer.refineObject(myObject,{//...});})1516
cop.create("UndoLayer").beGlobal().refineClass(TextMorph,{onKeyDown:function($proceed,evt){return$proceed(evt)}}).refineObject(myObject,{//..})16
Version4F:BetterNames20
null70