Assignment Attempt

The use of specific JADE features and proposals for new feature suggestions
ConvertFromOldNGs
Posts: 5321
Joined: Wed Aug 05, 2009 5:19 pm

Assignment Attempt

Postby ConvertFromOldNGs » Fri Aug 07, 2009 10:40 am

by Carl Ranson >> Thu, 18 May 2000 4:01:00 GMT

I think Jade should support the Assignment Attempt operation (?=).

This performs an assignment if the operands are type compatable, otherwise it sets the left operand to null.

This would remove the need for a lot of typecasting and calls to isKindOf in Jade...

eg

vars
s : Species;
ss : Subspecies;begin

s ?= <treeview.currentObject>;
ss ?= <treeview.currentObject>;
end;

would be equivalent to the current:

vars
s : Species;
ss : Subspecies;begin

s := null;
ss := null;
if <treeview.currentObject>.isKindOf(Subspecies) then
ss := <treeview.currentObject>.itemObject.Subspecies;
elseif <treeview.currentObject>.isKindOf(Species) then
s := <treeview.currentObject>.Species;
endif;
end;

Anyone from the plan like this idea enough to sneak it in ? :)
Regards,
CR

ConvertFromOldNGs
Posts: 5321
Joined: Wed Aug 05, 2009 5:19 pm

Re: Assignment Attempt

Postby ConvertFromOldNGs » Fri Aug 07, 2009 10:40 am

by Carl Ranson >> Thu, 18 May 2000 4:06:41 GMT

Oh, btw.....

In the example I've given Species and Subspecies are siblings in the class hierachy:

ie
Object
<Some Parent Class>
Species
SubSpecies

therefore a SubSpecies object isn't a Species object as well.
CR

ConvertFromOldNGs
Posts: 5321
Joined: Wed Aug 05, 2009 5:19 pm

Re: Assignment Attempt

Postby ConvertFromOldNGs » Fri Aug 07, 2009 10:40 am

by JADE Kid - Ray Hidayat >> Thu, 18 May 2000 6:06:42 GMT

That isn't a bad idea. I don't know where I'll use it. But is is a good idea. But if the assignment fails, it should leave the thing on the left side.

I think that I would use it when assigning things from the Any type to some other type. I don't know why you would have an any type, because I think those are pointless in most situations. But even though I probably would never use it... It is a good idea.

--
Ray Hidayat
JADE Kid - 2000
www.jadekids.com

ConvertFromOldNGs
Posts: 5321
Joined: Wed Aug 05, 2009 5:19 pm

Re: Assignment Attempt

Postby ConvertFromOldNGs » Fri Aug 07, 2009 10:40 am

by Wilfred Verkley >> Fri, 19 May 2000 4:43:58 GMT

IMHO this is a not such a hot idea. Strong typing is good feature, because it imposes strucure on your programming and makes it more clear what is happening. If you are typecasting a lot, or doing a lot of "isKindOf" tests its usually a sign of bad structure (why isnt this conditional behaviour in polymorphic methods?).

Maybe its my pascal heritage showing...

Wilfred.

ConvertFromOldNGs
Posts: 5321
Joined: Wed Aug 05, 2009 5:19 pm

Re: Assignment Attempt

Postby ConvertFromOldNGs » Fri Aug 07, 2009 10:41 am

by JADE Kid - Ray Hidayat >> Fri, 19 May 2000 5:46:06 GMT

That is true. Strong typing is probably the best feature in JADE, unlike C! Maybe this attempting operation isn't a great idea.

BTW - Jade is based on the language Modula, which is based on Pascal, which is based on Algol.

--
Ray Hidayat
JADE Kid - 2000
www.jadekids.com

ConvertFromOldNGs
Posts: 5321
Joined: Wed Aug 05, 2009 5:19 pm

Re: Assignment Attempt

Postby ConvertFromOldNGs » Fri Aug 07, 2009 10:41 am

by Robert Barr >> Mon, 22 May 2000 23:46:19 GMT
BTW - Jade is based on the language Modula, which is based on Pascal, which is based on Algol.

I think you are suggesting that the syntax and semantics of the JADE *language* is based on Modula. Just making the point that JADE offers more than just a language.

ConvertFromOldNGs
Posts: 5321
Joined: Wed Aug 05, 2009 5:19 pm

Re: Assignment Attempt

Postby ConvertFromOldNGs » Fri Aug 07, 2009 10:41 am

by Krull >> Tue, 23 May 2000 6:27:58 GMT
I think you are suggesting that the syntax and semantics of the JADE *language* is based on Modula.

Actually, the JADE language is based more on the Wirth's later development Oberon, which evolved from Modula-2.
It is interesting to note that in the progression from Pascal, through Modula-I, II and III, the languages became more complex as further language syntax&sematics were added. In Oberon, however, much of the complexity introduced in Modula was discarded; The Oberon language is not only smaller and less complex than either Pascal or Modula it is more user extensible (Oberon is more of a distillation of the best features from Pascal and Modula-2). JADE shares the 'conceptual economy' approach taken by Wirth in designing the Oberon language but probably takes it a step further. As an illustration of this philosphy, the very first *prototype* of the JADE compiler/interpreter provided a repeat .. until instruction (as does Pascal, Modula and even Oberon), as the language was developed beyond its prototype stage, 'repeat until' was dropped.

Apart from Wirth's approach to keeping it simple, the only real language concept gleaned from Oberon was the notion of a 'Type Guard' .
Just making the point that JADE offers more than just a language.

Good point to make (Oberon was also more than a language but it didn't have an integrated database)

ConvertFromOldNGs
Posts: 5321
Joined: Wed Aug 05, 2009 5:19 pm

Re: Assignment Attempt

Postby ConvertFromOldNGs » Fri Aug 07, 2009 10:41 am

by Carl Ranson >> Sun, 21 May 2000 21:42:05 GMT

Strong typing is a good idea! But I don't see why you think this feature circumvents it, it simply hides away the existing mechanism.

Yes, I agree that the type casting shouldn't be necessary and in a perfect world it should be handled by polymorphism. But I'm dealing with real world scenarios here.

Consider, for example, storing different types of objects in the cells of a jade table. Retrieving these and working out what you've got back DOES require the use of isKindOfs and typecasts.

CR

ConvertFromOldNGs
Posts: 5321
Joined: Wed Aug 05, 2009 5:19 pm

Re: Assignment Attempt

Postby ConvertFromOldNGs » Fri Aug 07, 2009 10:41 am

by Robert Barr >> Tue, 23 May 2000 0:00:57 GMT

I've heard this OO purist view before - that using "isKindOf" indicates
a structural oversight. In Carl's examples, is it practical (to obtain polymorphic nirvana) to specialise your listbox or table, (perhaps reimplementing listObject) to store and retrieve Species or Subspecies, etc?

Rob

ConvertFromOldNGs
Posts: 5321
Joined: Wed Aug 05, 2009 5:19 pm

Re: Assignment Attempt

Postby ConvertFromOldNGs » Fri Aug 07, 2009 10:41 am

by Torrie Moore >> Tue, 23 May 2000 0:44:14 GMT

From a OO purist's view I think you would and I know of some people who are. From a practical point of view I think it would create a huge number of classes that are not really needed. In most cases when you set or retreive an object from a list box / table you know what class the object is so can use a typecast without checking. Note you can typecast a null object without creating an exception.

Torrie


Return to “Feature Discussions”

Who is online

Users browsing this forum: No registered users and 15 guests

cron