Type annotation for block which returns a value?

31 views
Skip to first unread message

Rouan van Dalen

unread,
Apr 8, 2013, 11:41:21 AM4/8/13
to newspeak...@googlegroups.com
Hi,

Is there a way to write a type annotation for a Block that specifies the return type?

Something like:

    <[Integer, ^Boolean]>  (* takes an Integer value and returns a value of type Boolean *)

Regards
--Rouan.

Eliot Miranda

unread,
Apr 8, 2013, 12:50:57 PM4/8/13
to newspeak...@googlegroups.com
If there are arguments then '[' ( arg ':' ) * '|' type ']', e.g. <[:ActivationMirror| Boolean]>

Not sure if there are no arguments but I'd expect just '['type']', e.g. <[Object]>



Regards
--Rouan.



--
best,
Eliot

Rouan van Dalen

unread,
Apr 8, 2013, 12:59:30 PM4/8/13
to newspeak...@googlegroups.com
Thanks Eliot,

That makes sense.  I am browsing the type annotations for Kernel`Collections for some examples :)

I use C# as my day job programming language and I have come to like LINQ.  I am an my way to create
a LINQ-like library for Newspeak for my own use at first.  Is this something that might be useful to put back
into Newspeak as a general, reusable module?

Regards
--Rouan

Gilad Bracha

unread,
Apr 8, 2013, 1:34:40 PM4/8/13
to newspeak...@googlegroups.com
Yes. You should look at Glorp, which is a Smalltalk library for accessing databases.
--
Cheers, Gilad

Frank Shearar

unread,
Apr 8, 2013, 1:46:23 PM4/8/13
to newspeak...@googlegroups.com
LINQ's only superficially about databases. It's much more about the
standard functional tricks for enumerable things - select, filter,
reduce, etc - only using database-y names. So "reduce" is "Aggregate",
"map" is "Select" (as in "select foo, bar from baz " maps baz-like
things into tuples), "filter" is "Where".

ROE might be another good thing to look at: it's an attempt at
bringing relational algebra to objects.

frank

Gilad Bracha

unread,
Apr 8, 2013, 1:52:14 PM4/8/13
to newspeak...@googlegroups.com
On Mon, Apr 8, 2013 at 10:46 AM, Frank Shearar <frank....@gmail.com> wrote:
LINQ's only superficially about databases.

Yes of course - but ... 
It's much more about the
standard functional tricks for enumerable things - select, filter,
reduce, etc - only using database-y names. So "reduce" is "Aggregate",
"map" is "Select" (as in "select foo, bar from baz " maps baz-like
things into tuples), "filter" is "Where".

That I don't care about. The collection interface is fine - the issue is being able to use it uniformly for things other than in-memory collections - databases, XML, DOM or whatever.  That an any reasonable extensions (orderedBy:) etc. WHich is why Glorp is highly relevant. I'll talk to Alan Knight.



--
Cheers, Gilad

Rouan van Dalen

unread,
Apr 8, 2013, 2:41:01 PM4/8/13
to newspeak...@googlegroups.com
Thanks Frank,

I will have a look at ROE.

The part of LINQ I refer to is the methods for working with collections yes.  Not really interested in
in writing a data access layer :)

Regards
--Rouan

Gilad Bracha

unread,
Apr 8, 2013, 6:00:08 PM4/8/13
to newspeak...@googlegroups.com
On Mon, Apr 8, 2013 at 11:41 AM, Rouan van Dalen <r...@sftreal.co.za> wrote:
Thanks Frank,

I will have a look at ROE.

The part of LINQ I refer to is the methods for working with collections yes.  Not really interested in
in writing a data access layer :)

I suspect our interests in LINQ don't quite align, but maybe you could be more specific about what you are trying to do? 

--
Cheers, Gilad

Rouan van Dalen

unread,
Apr 9, 2013, 12:37:17 PM4/9/13
to newspeak...@googlegroups.com, gi...@bracha.org
Gilad,

At this stage all I am trying to do is create a nice interface for querying collections which look like LINQ
because I find the interface is easy to work with, and because I am building quite deep models with lots
of collections I will be writing lots of collection query code.

I am not trying to implement LINQ in Newspeak per se, just something that has a similar interface.
Also not trying to create a uniform interface for data access.

Instead of LINQ, we could call it Collection queries.  I just wanted to check with the Newspeak
community if something like this would be useful to add as a standard module.

If not, I will still create it for my own use, but won't bother trying to get it back into Newspeak :)

Regards
--Rouan

Gilad Bracha

unread,
Apr 9, 2013, 7:08:49 PM4/9/13
to newspeak...@googlegroups.com
Rouan,

Let's see what you come up with and then we can decide if it is something we want in the platform.
--
Cheers, Gilad

Rouan van Dalen

unread,
Apr 10, 2013, 2:37:11 AM4/10/13
to newspeak...@googlegroups.com, gi...@bracha.org
Great

I will let you know as soon as I have something I think is worth sharing.

Regards
Reply all
Reply to author
Forward
0 new messages