[Seaside] Dynamic typing in smalltalk

John McKeon p3anoman at gmail.com
Fri Oct 29 16:56:22 UTC 2010


On Fri, Oct 29, 2010 at 12:43 PM, Alexandre BP <abalonpe at ulb.ac.be> wrote:

>  thank you for your reply
> I have a class named "PaperBibli" which keeps a list of bibliographic
> entries.
> Those entries are of different type: Article, Book, Conference,...
> Every type has its own fields such as: author,title,...
>
>  --> I created SubClasses of "PaperBibli" for each type so that when I
> instanciate an bibliographic entry I don't have lots of variables(fields)
> which are empty because not required in a particular type.
> The problem is that when I instanciate my bibliographic entry I still don't
> know of which type it is because the user tell me so by choosing in a scroll
> list.
>
> I hope that my explanation is clear
>

Now its clear. Your scroll list, in Seaside, can hold the subClasses of
Bibli as its list items (but can render labels: for each class). Then in the
scroll list's callback: the value handed to it will be the selected subclass
(NOT the label), so that you WILL know which class to create.
Cool huh?

html select
   list: PaperBibli allSubclasses;
   labels: [ :val | val class ];  <-- "implement a label message in each
class to return a nice string then the block would be [ :val | val label ]"
   callback: [ :cls | someVar := cls new ];  <---cls is one of the
subclasses!
  .....&etc

Hope that helps
John

>
>
>
>
> ------------------------------
> Date: Fri, 29 Oct 2010 12:24:22 -0400
> Subject: Re: [Seaside] Dynamic typing in smalltalk
> From: sean at monkeysnatchbanana.com
> To: seaside at lists.squeakfoundation.org
>
>
> There are types in smalltalk. Each object has a type.
>
> That aside, what are you trying to accomplish with your example below?
>
>
> On Fri, Oct 29, 2010 at 12:13 PM, Alexandre BP <abalonpe at ulb.ac.be> wrote:
>
>
> Hello,
>
> I would like to know if it is possible to apply dynamic typing in
> smalltalk. For example, If I want to use polymorphism, it would be:
>       var := Class new.
> var := (SubClass1) message.
> var := (SubClass2) message.
>
> Where message from SubClass1 is different then the one from SubClass2.
> Is there any solution for my problem?
> I know that there is no type in smalltalk but there is definitely a way to
> use polymorphism right?
>
> Thank you in advance,
> Regards
> alex
>
> _______________________________________________
> seaside mailing list
> seaside at lists.squeakfoundation.org
> http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside
>
>
>
> _______________________________________________ seaside mailing list
> seaside at lists.squeakfoundation.org
> http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside
>
> _______________________________________________
> seaside mailing list
> seaside at lists.squeakfoundation.org
> http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside
>
>


-- 
http://john-mckeon.us
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.squeakfoundation.org/pipermail/seaside/attachments/20101029/d06014d6/attachment.htm


More information about the seaside mailing list