comp.lang.ada
 help / color / mirror / Atom feed
From: "Dmitry A. Kazakov" <mailbox@dmitry-kazakov.de>
Subject: Re: Ada Interfaces and the Liskov Substitution Principle
Date: Wed, 30 May 2007 10:43:47 +0200
Date: 2007-05-30T10:41:31+02:00	[thread overview]
Message-ID: <c02nfnffh323$.1wtorvl0fxun5$.dlg@40tude.net> (raw)
In-Reply-To: 1180510814.812025.251580@u30g2000hsc.googlegroups.com

On 30 May 2007 00:40:14 -0700, Maciej Sobczak wrote:

> On 29 Maj, 19:07, "Dmitry A. Kazakov" <mail...@dmitry-kazakov.de>
> wrote:
> 
>>> We are talking about real:
>>
>>> X := Y;
>>
>> Huh, how are going to design a non-referential container of T'Class?
> 
> I don't. :-)
> Polymorphism and references come hand in hand if you need the ability
> to reassign. Copy-initialization is the only place where you can
> safely get away with "values" of T'Class.

Are you going to sell me pointers, right here, in c.l.a? (:-))

Referential semantics is an implementation detail. You propose to expose it
to defend a fiction. But it would be in vain, because assigning class-wide
references in this context is semantically equivalent to assigning the
targets.

> I think that the mess has its source in the push to have T'Class
> behaving like normal value.

This is all meta-programming is about: dealing with polymorphic values =
programming in terms of sets of types.

>>> I say that you need one type String, that possibly uses strategy
>>> internally to delegate details like encoding. You don't need encoding
>>> to "leak out" at the level of types that the final user operates on.
>>
>> That would be indeed a mess. How would you pass an UTF-8 string to GTK+
>> which knows nothing about your fancy patterns?
> 
> Then it should know.

It cannot, it is ANSI C.

> Otherwise there is no way it can interpret
> correctly what I pass as parameters, unless you want to have
> "implicit" conversions for parameters.

To interpret, to convert etc, all this requires a distinct type. Which is
why different representations have to be mapped to different types.

>> Why don't you use the
>> advantages of the types system?
> 
> I do use it, I just don't elevate implementation details to the level
> of type that is handled directly by the user.

I don't see any handling required. But let it be, then how is it different
from your void * approach? When you create a void * you have to somehow
specify the hidden parameter of the case-statement:

   void * X = Create_UTF8 ("foo");

With types you just specify the type of the object instead:

   X : UTF8_String := "foo";

>>> You can (and should) have dispatching internally in the implementation
>>> of operations of String. I'm not proposing any case statements here!
>>
>> Here you are. What is the difference between internally and externally
>> dispatching assignments?
> 
> Assignment is an operation that is meaningful syntactically - that's
> why it is so tempting. Internally you can have anything else,
> including regular subprogram calls that will do necessary conversions.

But not assignments? The question is how do I do dispatching assignment?
Your point was that I shall not do it publicly. But, may I dispatch
privately? If yes then how? And where is any difference? If not, then the
only way left is a case-statement.

>> Static polymorphism does not allow mixing types.
> 
> ?

Instances from a statically polymorphic class of types are unrelated types.
You cannot have any polymorphic object from that class, only specific
objects. For the same reason you cannot have any class-wide operation from
that class.
 
>> Further you cannot design
>> a library for formatting strings which would not be generic itself.
> 
> 1. So?

Write an editor for such strings, store a string, send it over the network,
do anything after uninstalling the compiler ...

> 2. Yes, I can. Just use arbitrary string type for formatting and then
> convert to the destination type.

Why should I bother to have UTF-8 or ASCII strings if anything is
Wide_..._Wide_Unbounded anyway? What are you going to do if the endianess
of Wide x n Character does not fit your machine?

>> The former is quite possible and IMO is the only right way to go. Note that
>> the language should also allow declaring symmetries of the methods to
>> reduce the number of independent variants.
> 
> Yes, but that reduces the complexity by a constant only, the problem
> is still fundamentally squared.

It is how it is. No matter how you would handle them, you have to all of
them. Whatever pattern you use, you will have to deal with this number of
cases. Do you seriously propose to define some of the cases improperly,
just because there are too many of them? (:-))

-- 
Regards,
Dmitry A. Kazakov
http://www.dmitry-kazakov.de



  reply	other threads:[~2007-05-30  8:43 UTC|newest]

Thread overview: 81+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-05-23 19:47 Ada Interfaces and the Liskov Substitution Principle Stefan Lucks
2007-05-23 20:32 ` Ludovic Brenta
2007-05-23 22:00   ` Randy Brukardt
2007-05-24  0:56     ` Anh Vo
2007-05-24 18:27     ` Pascal Obry
2007-05-24 18:39       ` Dmitry A. Kazakov
2007-05-24 18:51         ` Pascal Obry
2007-05-24 22:44         ` Randy Brukardt
2007-05-24  6:57   ` Stefan Lucks
2007-05-23 20:54 ` Maciej Sobczak
2007-05-23 21:58   ` Randy Brukardt
2007-05-24  7:29     ` Maciej Sobczak
2007-05-24  8:02       ` Dmitry A. Kazakov
2007-05-24 12:58         ` Maciej Sobczak
2007-05-24 13:42           ` Dmitry A. Kazakov
2007-05-24 22:08           ` Robert A Duff
2007-07-01  1:00             ` David Thompson
2007-05-24 22:58           ` Randy Brukardt
2007-05-25  7:52             ` Maciej Sobczak
2007-05-25  8:21               ` Dmitry A. Kazakov
2007-05-25 20:27                 ` Maciej Sobczak
2007-05-26  7:48                   ` Dmitry A. Kazakov
2007-05-27  8:30                     ` Maciej Sobczak
2007-05-27 10:04                       ` Dmitry A. Kazakov
2007-05-29  8:03                         ` Maciej Sobczak
2007-05-29 13:18                           ` Dmitry A. Kazakov
2007-05-29 13:32                             ` Dmitry A. Kazakov
2007-05-29 15:34                             ` Maciej Sobczak
2007-05-29 17:07                               ` Dmitry A. Kazakov
2007-05-30  7:40                                 ` Maciej Sobczak
2007-05-30  8:43                                   ` Dmitry A. Kazakov [this message]
2007-05-30 12:54                                     ` Maciej Sobczak
2007-05-30 13:56                                       ` Dmitry A. Kazakov
2007-05-30 16:49                                         ` vgodunko
2007-05-30 20:52                                         ` Maciej Sobczak
2007-05-31  8:15                                           ` Dmitry A. Kazakov
2007-05-31 13:46                                             ` Maciej Sobczak
2007-06-01  7:29                                               ` Dmitry A. Kazakov
2007-06-01 13:32                                                 ` Maciej Sobczak
2007-06-01 14:53                                                   ` Dmitry A. Kazakov
2007-06-01 20:31                                                     ` Maciej Sobczak
2007-06-02  8:19                                                       ` Dmitry A. Kazakov
2007-06-02 16:49                                                         ` Maciej Sobczak
2007-06-03  7:09                                                           ` Dmitry A. Kazakov
2007-06-03 22:04                                                             ` Maciej Sobczak
2007-06-04  8:08                                                               ` Dmitry A. Kazakov
2007-06-04 17:02                                                                 ` Maciej Sobczak
2007-06-05  8:35                                                                   ` Dmitry A. Kazakov
2007-06-05 22:12                                                                     ` Maciej Sobczak
2007-06-06  8:21                                                                       ` Dmitry A. Kazakov
2007-06-06 14:46                                                                         ` Maciej Sobczak
2007-06-06 15:11                                                                           ` Maciej Sobczak
2007-06-06 15:32                                                                       ` Markus E Leypold
2007-05-24 10:42       ` Georg Bauhaus
2007-05-24 13:41         ` Dmitry A. Kazakov
2007-05-25 16:59         ` Markus E Leypold
2007-05-28  9:52           ` Georg Bauhaus
2007-05-28 11:50             ` Dmitry A. Kazakov
2007-05-28 23:32               ` Georg Bauhaus
2007-05-29 12:05                 ` Dmitry A. Kazakov
2007-05-29 13:33                 ` Georg Bauhaus
2007-05-29 17:29                   ` Dmitry A. Kazakov
2007-05-29 20:46                     ` Georg Bauhaus
2007-05-30  7:53                       ` Dmitry A. Kazakov
2007-05-30 13:18                       ` Georg Bauhaus
2007-05-31 10:27                         ` Dmitry A. Kazakov
2007-05-31 11:44                         ` Georg Bauhaus
2007-06-01  7:37                           ` Dmitry A. Kazakov
2007-06-01 10:07                             ` Markus E Leypold
2007-06-01 11:41                             ` Georg Bauhaus
2007-06-01 13:07                               ` Dmitry A. Kazakov
2007-05-28 13:47             ` Markus E Leypold
2007-05-28 23:12               ` Georg Bauhaus
2007-05-28 13:56             ` Markus E Leypold
2007-05-28 23:00               ` Georg Bauhaus
2007-05-24  7:39 ` Dmitry A. Kazakov
2007-05-24 11:12   ` Stefan Lucks
2007-05-24 13:56     ` Dmitry A. Kazakov
2007-05-24 14:41       ` Stefan Lucks
2007-05-24 15:46         ` Dmitry A. Kazakov
2007-05-24 15:00       ` Georg Bauhaus
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox