Gravatar

Re: Reducers in Smalltalk


There is already a way to compose the blocks used by select:/collect: etc. and avoid intermediate
collections. For example in the case of 
test1 = [:i| I odd].
test2 := [:i| (i\\3) = 0].
((0 to: 100) select: test1) select: test2 

Does indeed iterate over the collection twice. But:

(0 to: 100) select: [:i| (test1 value: i) and: [test2 value: i]]

Only iterates over it once with the two tests composed.

If you want nicer syntax you could create a BlockCollection class with ways to compose blocks. For example:
aBlockCollection := (test1 & test2) || test3.

Then modify select: to take a block collection so you can write (1 to: 100) select: aBlockCollection.

Extensions to support block collections for collect could also be written say:
aBlockCollection := map1, map2, map3.
Then (1 to: 100) collect: aBlockCollection would give you the result of feeding the output of each block
into the next.

Joerg
-----Original Message-----
From: vwnc-bounces <at> cs.uiuc.edu [mailto:vwnc-bounces <at> cs.uiuc.edu] On Behalf Of Steffen Märcker
Sent: Friday, May 17, 2013 10:06 AM
To: Michael Lucas-Smith
Cc: vwnc <at> cs.uiuc.edu
Subject: Re: [vwnc] Reducers in Smalltalk
(Continue reading)

Steffen Märcker | 15 May 2013 11:25
Picon

Re: [ANN] DoubleAgents: A Test Double Library for Visualworks

Say, we have MyClass that defines myMethod on the class side, e.g.

> MyClass class>>myMethod
>    "fancy stuff"

The code to be tested is given that class in some way and uses it, say

> result := suspectObject doStuffWithClass: MyClass.

Can I stub myMethod with DoubleAgents? Maybe similar to

> classDouble := MyClass class doubleAgent.
> classDouble stub: #myMethod return: 42.
> result := suspectObject doStuffWithClass: classDouble.

Regards, Steffen

Am 14.05.2013, 20:11 Uhr, schrieb Randy Coulman <rcoulman <at> gmail.com>:

> What do you mean by "mocking a class"?  Can you give me an example?
>
> Thanks,
> Randy
>
>
> On Tue, May 14, 2013 at 10:12 AM, Steffen Märcker <merkste <at> web.de> wrote:
>
>> Hi Randy,
>>
>> thanks for the explanation. DoubleAgents appear really interesting to  
(Continue reading)

Steffen Märcker | 9 May 2013 16:40
Picon

Reducers in Smalltalk

Hi,

out of curiosity I did an initial port of Clojure's Reducers library. I've  
just pushed it to the public repository. It is by no means complete or  
optimized. In fact, I ask you for your impressions and ideas where to go  
 from here.

So, what's in here?
Reducers builds upon the simple abstraction that a collection is a  
reducible object, i.e., an object that understands #reduce:init:. It  
provides fundamental collection operations similar to classical methods,  
e.g., like #collect:, but offers specific advantages:
- Reducers are composable and reusable.
- Memory efficiency, since no intermediate collections are constructed.
- Enable collection operations on custom types simply by implementing  
#reduce:init:.
- Possibility of parallel operations on collections, e.g., with  
Polycephaly 2.

For example, the sum of odd numbers could be computed like this:

| col red |
col := (1 to: 10**6).
(Reducer filter: #odd from: col) reduce: #+ init: 0.

"composition of reducers works like this:"
red := (Reducer filter: #odd) <> (Reducer map: #squared).
(red from: col) reduce: #+ init: 0.

Some questions:
(Continue reading)

Vincent Lesbros | 9 May 2013 15:16
Picon

indexedType: #illegal

What is the meaning of "illegal" indexedType ?
If I file out the package with this, I can't read it again without
replacing the "illegal" by "none"

Smalltalk.UnPackage defineClass: #UneClasse
	superclass: #{Core.Object}
	indexedType: #illegal
	private: false
	instanceVariableNames: ''
	classInstanceVariableNames: ''
	imports: ''
	category: ''
Vincent Lesbros | 9 May 2013 15:07
Picon

External interfaces long long typedef returns a CPointer

Hi,

I have defined an external interface to a C .dll
from the following header :

--header.h--
typedef __int64	compteur;

compteur  fonction	(void *ptr1, const float *ptr2, compteur nombre) ;

-external interface Interface defs :

compteur
	<C: typedef long long compteur>

fonction: ptr1 with: ptr2 with: items
	<C: compteur fonction(void *ptr1, const float * ptr2, compteur items)>
	^self externalAccessFailedWith: _errorCode

When I call the function with this definition, the function fails and
the return value is erroneously instantiated with an (invalid)
CPointer (instead of the expected 64bit integer).
If I replace the typedef by the type long long as the return value,
Like this :

fonction: ptr1 with: ptr2 with: items
	<C: long long fonction(void *ptr1, const float * ptr2, compteur items)>
	^self externalAccessFailedWith: _errorCode

The function works well, and the return value is correct.
(Continue reading)

maarten.mostert | 9 May 2013 13:03

Windows7LookExtraCairoPolicy

Hi,

 

I just published  a package called Windows7LookExtraCairoPolicy

 

It loads without hirks in a vanilla 7.9.1 image does not use any overrides and updates list and treeView selections.

 

Have fun,

 

Maarten,

_______________________________________________
vwnc mailing list
vwnc <at> cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/vwnc
Milan Čermák | 5 May 2013 09:42
Picon

[ANN] Gnome2 look

Hi all,
I'd like to announce that I've published a look redesign matching Gnome2 
desktop. You can find it in UILooks-Gnome package in public repository.

Attached is a screenshot of VWnc 7.9.1 in Gnome2 look.

Gnome2 look adaptation is complete and stand-alone. All views and 
controllers are redesigned to match Gnome2. The package does not require 
any other look to be loaded. The look adds itself to settings menu and 
sets itself as default look for Linux and Solaris.

Bug reports are welcome.

Cheers and enjoy,
Milan Čermák
_______________________________________________
vwnc mailing list
vwnc <at> cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/vwnc
Steve Cline | 4 May 2013 21:59
Picon
Favicon

[ANN] JSONReader 1.17

minor tweaks:

added jsonRead as unary implementation of JsonReader readFrom: aString
readStream

throw an error if writing a Dictionary with asJson if the key is not a
string (already a check on the read side; this was to prevent me from
writing a dictionary that I can't read)

JSONReaderTests updated to 1.2

--
View this message in context: http://forum.world.st/ANN-JSONReader-1-17-tp4685698.html
Sent from the VisualWorks mailing list archive at Nabble.com.
Johannes Brauer | 4 May 2013 17:29
Picon

first MOOC about OOP with Smalltalk and Seaside?

Dear Smalltalkers!

There is an initiative for funding the development of massive open online courses (moocs) by the
"Stifterverband für die deutsche Wissenschaft"" (http://www.stifterverband.info/ueber_den_stifterverband/english/index.html).
You can get information about a running competition (MOOC PRODUCTION FELLOWSHIP) here: https://moocfellowship.org.
Following the link https://moocfellowship.org/submissions/objektorientierte-programmierung-von-web-anwendungen-von-anfang-an
YOU CAN VOTE for the course offered by me resp. the NORDAKADEMIE (www.nordakademie.de). For voting you
have to register by Facebook or email only.

The MOOC we want to build will be based on a blended learning course we have been pursuing as a first year
programming course under the headline "object oriented development of web applications" since a couple
of years. During this class the students learn object oriented programming from the beginning using
Smalltalk and Seaside.

Since the material of our blended learning course is in German the first version of the projected MOOC will
be in German, too. Getting one of the awards should offer the possibility to build an English version later on.

I would be delighted if you could adjust our Smalltalk-MOOC project by voting for the course

https://moocfellowship.org/submissions/objektorientierte-programmierung-von-web-anwendungen-von-anfang-an

Thank you very much

Johannes Brauer

Prof. Dr.-Ing. Johannes Brauer
Dean of Computer Science Departement
Tel.: 04121 409030
Fax.: 04121 409040
e-mail: brauer <at> nordakademie.de
e-mal priv.: brauer <at> acm.org

________________________________

Staatlich anerkannte private Fachhochschule
NORDAKADEMIE
Gemeinnützige Aktiengesellschaft
Köllner Chaussee 11
25337 Elmshorn

Vorstand:
Prof. Dr. Georg Plate (Vorsitzender), Dipl.-Ing. Jörg Meier (stellv. Vorstand)

Vorsitzender des Aufsichtsrats:
Dr. h.c. Hans-Heinrich Bruns

Sitz:
Elmshorn, Amtsgericht Pinneberg, HRB 1682
Ivo Roefs | 3 May 2013 16:37
Picon

xmlToSmalltalkBinding heteregeneous collection, item class based on element content

Hi,

I'm trying to create an xmlToSmalltalkBinding to marshal/unmarshal following 2 xml elements.
(In the context of parsing Google API Contact feeds)

*** XML Element 1 ****
xml1 := '<feed>
<entry>
<category name="user"/>
<firstName>Ivo</firstName>
<lastName>Roefs</lastName>
</entry>
</feed>'
desiredObject := (Feed new)
entries: (User new firstName: 'Ivo'; lastName: 'Roefs'; yourself);
yourself

*** XML Element 2 ****
xml2 := '<feed>
<entry>
<category name="group"/>
<groupName>Smalltalkers</groupName>
</entry>
</feed>'
desiredObject := (Feed new)
entries: (Group new groupName: 'Smalltalkers'; yourself);
yourself
I started of with following binding description, but got stuck...
I can't figure out how to describe "entry" in the "feed" binding so that it refers to both User an Group. 
<schemaBindings>
<xmlToSmalltalkBinding targetNamespace="targetNamespace="urn:webservices"  defaultClassNamespace="MyCorp">
<object name="feed" smalltalkClass="Feed">
<element name="entry" aspect="entries" xpath="entry[category[ <at> name='user']]"  maxOccurs="unbounded" minOccurs="0" ref="entry"/>
</object>
<object name="user" smalltalkClass="User">
<attribute name="firstName" ref="xsd:string"/>
<attribute name="lastName" ref="xsd:string"/>
</object>
<object name="group" smalltalkClass="Group">
<attribute name="groupName" ref="xsd:string"/>
</object>
</xmlToSmalltalkBinding>
</schemaBindings>

regards,
Ivo Roefs
_______________________________________________
vwnc mailing list
vwnc <at> cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/vwnc
Suresh Kumar | 2 May 2013 18:20
Picon

GLORP and DB2

All,

I am working in a project which is in oracle and trying to make it to DB2 compatible. The GLORP for oracle we are using is very old. I have added the DB2 GLORP support from VW7.8 to the existing code and getting the error Glorp.DB2Sequence(Object)>>doesNotUnderstand: tableToSelectFromIn:for:  .

 The selector tableToSelectFromIn:for: is implemented only in PGSequence but not in DB2Sequence. Am I missing something or a bug? 

Also I loaded the glorp in  a VW7.9.1 vanilla image and checked to see any of my code overloaded during the porting, but I don't think.  If I could implement tableToSelectFromIn:for: in DB2Sequence, my problem may get resolved. Please suggest.



Thanks in advance,

Suresh

Glorp.DB2Sequence(Object)>>doesNotUnderstand:
Receiver:
a Glorp.DB2Sequence
Instance Variables:
reservedNumbers = an OrderedCollection[0]
name = 'SEQUENCE'
tableSelectCommand = nil
schema = nil
count = 0
sequenceIncrement = 1
accessProtect = a Semaphore[0]
Arguments:
t1 = a Message with selector: #tableToSelectFromIn:for: and arguments: #(a Glorp.GlorpSession a Glorp.DatabaseTable(TSK_DESC))
Temporaries:
t2 = a MessageNotUnderstood
t3 = nil
Context PC = 25

----------------------------------------------------------------------
Glorp.DB2Sequence(Glorp.NamedSequence)>>reserveViaTableSelect:in:for:
Receiver:
a Glorp.DB2Sequence
Instance Variables:
reservedNumbers = an OrderedCollection[0]
name = 'SEQUENCE'
tableSelectCommand = nil
schema = nil
count = 0
sequenceIncrement = 1
accessProtect = a Semaphore[0]
Arguments:
t1 = 1
t2 = a Glorp.GlorpSession
t3 = a Glorp.DatabaseTable(TSK_DESC)
Temporaries:
t4 = nil
t5 = nil
Context PC = 7

----------------------------------------------------------------------
Glorp.DB2Sequence(Glorp.NamedSequence)>>reserveSequenceNumbers:in:for:
Receiver:
a Glorp.DB2Sequence
Instance Variables:
reservedNumbers = an OrderedCollection[0]
name = 'SEQUENCE'
tableSelectCommand = nil
schema = nil
count = 0
sequenceIncrement = 1
accessProtect = a Semaphore[0]
Arguments:
t1 = 1
t2 = a Glorp.GlorpSession
t3 = a Glorp.DatabaseTable(TSK_DESC)
Temporaries:
t4 = 1
t5 = nil
Context PC = 18

----------------------------------------------------------------------
optimized [] in [] in Glorp.UnitOfWork>>reserveSequenceNumbers
Receiver:
an UndefinedObject
Arguments:
t4 = a Glorp.DB2Sequence(SEQUENCE)
Temporaries:
.t3 = an OrderedCollection[1]
.self = a Glorp.UnitOfWork
.t2 = a Glorp.DatabaseTable(TSK_DESC)
Context PC = 12

----------------------------------------------------------------------
OrderedCollection>>do:
Receiver:
an OrderedCollection
Instance Variables:
firstIndex = 1
lastIndex = 1
Arguments:
t1 = BlockClosure [] in [] in Glorp.UnitOfWork>>reserveSequenceNumbers
Temporaries:
t2 = 1
t3 = 1
Context PC = 17

----------------------------------------------------------------------
optimized [] in Glorp.UnitOfWork>>reserveSequenceNumbers
Receiver:
an UndefinedObject
Arguments:
t2 = a Glorp.DatabaseTable(TSK_DESC)
t3 = an OrderedCollection[1]
Temporaries:
.self = a Glorp.UnitOfWork
Context PC = 13

Thanks,
-Suresh

_______________________________________________
vwnc mailing list
vwnc <at> cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/vwnc

Gmane