SmaCC/Babel & Python
Marcus Denker
denker at iam.unibe.ch
Tue Feb 8 22:30:25 UTC 2005
Am 08.02.2005 um 23:16 schrieb Marcus Denker:
>
>> (Also, has anyone tried getting the Squeak & python
>> class-hierarchies to
>> interoperate?)
>
> No, for loading real python it's not good enough (that is: not real
> python).
> Another problem of course is that most python libs contains huge parts
> written in C.
>
>
Maybe this was somewhat miss-leading. (I miss-understood the question).
As the Babel-Python-Example class is a normal Squeak class, this class
is of course
is completely compatible to the squeak classes (it is one).
You can see that this is a normal Sunit testcase:
TestCase subclass: #PythonClass
instanceVariableNames: 'a b c d '
classVariableNames: 'A B C '
poolDictionaries: ''
category: 'Babel-Examples'
just on the class side with redefinitions for #compilerClass and
@parserClass
And the method like
def testWhile():
a = 1
while a < 10:
a = a + 1
b = a
self.assert(b == 10)
calls the normal assert of the TestCase superclass (which is written in
Squeak).
Or (other syntax):
function testForIn() {
var a,c,i;
a = new OrderedCollection;
a.add(1);
a.add(2);
for (i in a) { c = i; }
this.assert(c == 2);
a.add(4);
for (i in a) { c = i; }
this.assert(c == 4);
return c;
}
with OrderedCollection beeing a normal Squeak class...
Marcus
More information about the Squeak-dev
mailing list
|