Hello Ben, The limit you see for instance variables is due to: - Class format encoding (Memory manager dependent) - Bytecode set encoding (Bytecode set dependent)
The 255 inst var limit is enforced both by: - the V3 Memory manager - the SqueakV3PlusClosures bytecode set. Now we have Spur instead of V3 as a memory manager, which allows up to 65535 instance variables. The SistaV1 bytecodeset should reach production in Pharo 6 alpha any time soon, and combined with the Spur memory manager, it enforces a limit of 65535 instance variables instead of 255. Class variables are indeed a dictionary so there's no hard limit. On Mon, Sep 12, 2016 at 4:51 AM, Ben Coman <b...@openinworld.com> wrote: > Minor curiosity... I was wondering about the limits on the number of > instance variables and class variables (particularly the latter regarding > large FFI enumerations), so I produced a script to experiment with. > > Results: > * Class Variables seem to have no practical limit. Although running 6C > experiment a second time locks the image for about 3 minutes, but > eventually completes. > * Instance Variables limit is 255 or 256. This not clear since 256 works, > but the error message** for 257 says the limit is 255. > ** Error: genStorePopInstVarLong: index index 256 is out of range 0 > to 255 > > cheers -ben > > Here is the fun script... > "================================================" > "The experiment has two parameters (select by changing the #at: index): > _RANGE - Range of variables assigned. Note variables are declared > starting from 0001. > _TYPE - (i)instance variable or (C)lass variable" > > _RANGE := { > 1->9. "1. code validation" > 201->256. "2. instance variables limit" > 201->257. "3. instance variables Error: genStorePopInstVarLong: index > index 256 is out of range 0 to 255" > 201->299. "4. class variables keep going" > 901->999. "5. class variables go extreme" > 9901->9999. "6. class variables go ultra extreme" > } at: 1. > _TYPE := { > 'i'. "1. instance variables" > 'C' "2. class variables" > } at: 1. > > "Choose experiment parameters above" > > start := _RANGE key. > end := _RANGE value. > > "DECLARE VARIABLES" > vars := ''. > 1 to: end do: [:n| vars := vars, _TYPE, (n printPaddedWith: $0 to: 4), ' > ' ]. > vars. > Object subclass: #Test > instanceVariableNames: ((_TYPE = 'i') ifTrue: [vars] ifFalse: [ '' ]) > classVariableNames: ((_TYPE = 'C') ifTrue: [vars] ifFalse: [ '' ]) > poolDictionaries: '' > package: 'aaaa'. > > "First run needs to execute above separately to create the class referred > below" > > "ASSIGN VARIABLES" > body := ' > '. > start to: end do: [ :n| body := body , _TYPE, (n printPaddedWith: $0 to: > 4), ':=' , n printString , '. > ' ]. > body. > #Test asClass compile: 'assign ' , body. > > "INSPECT VARIABLES" > body := ' > ^{'. > start to: end do: [ :n| body := body , _TYPE, (n printPaddedWith: $0 to: > 4) , '. ' ]. > body. > Test compile: 'inspect ' , body , '} inspect'. > > Test new assign ; inspect. > >