Warning: mysqli::__construct(): (HY000/1203): User howardkn already has more than 'max_user_connections' active connections in D:\Inetpub\vhosts\howardknight.net\al.howardknight.net\includes\artfuncs.php on line 21
Failed to connect to MySQL: (1203) User howardkn already has more than 'max_user_connections' active connections
Warning: mysqli::query(): Couldn't fetch mysqli in D:\Inetpub\vhosts\howardknight.net\al.howardknight.net\index.php on line 66
Article <vdknqr$1428n$1@paganini.bofh.team>
Deutsch   English   Français   Italiano  
<vdknqr$1428n$1@paganini.bofh.team>

View for Bookmarking (what is this?)
Look up another Usenet article

Path: ...!news.mixmin.net!weretis.net!feeder8.news.weretis.net!newsfeed.bofh.team!paganini.bofh.team!not-for-mail
From: antispam@fricas.org (Waldek Hebisch)
Newsgroups: alt.folklore.computers,comp.os.linux.misc
Subject: Re: TeX and Pascal [was Re: The joy of FORTRAN]
Date: Thu, 3 Oct 2024 00:17:33 -0000 (UTC)
Organization: To protect and to server
Message-ID: <vdknqr$1428n$1@paganini.bofh.team>
References: <pan$96411$d204da43$cc34bb91$1fe98651@linux.rocks>   <mdd4j63pmo1.fsf_-_@panix5.panix.com> <oJ-cnQSrLZDYdGX7nZ2dnZfqnPWdnZ2d@earthlink.com> <vdatb6$1l4ch$8@dont-email.me> <vdauah$1lq1u$1@dont-email.me> <20240930110933.00002ec1@gmail.com> <appeal-20240930203239@ram.dialup.fu-berlin.de> <20240930135208.00004170@gmail.com> <OOP-20240930220855@ram.dialup.fu-berlin.de> <20240930162717.0000340b@gmail.com> <polymorphism-20241001105522@ram.dialup.fu-berlin.de>
Injection-Date: Thu, 3 Oct 2024 00:17:33 -0000 (UTC)
Injection-Info: paganini.bofh.team; logging-data="1181975"; posting-host="WwiNTD3IIceGeoS5hCc4+A.user.paganini.bofh.team"; mail-complaints-to="usenet@bofh.team"; posting-account="9dIQLXBM7WM9KzA+yjdR4A";
User-Agent: tin/2.6.2-20221225 ("Pittyvaich") (Linux/6.1.0-9-amd64 (x86_64))
X-Notice: Filtered by postfilter v. 0.9.3
Bytes: 2894
Lines: 57

In alt.folklore.computers Stefan Ram <ram@zedat.fu-berlin.de> wrote:
> John Ames <commodorejohn@gmail.com> wrote or quoted:
>>rather than having to remember the distinction between:
>>void sliceApple(apple * f)
>>and:
>>void slicePear(pear * f)
>>one could simply write:
>>fruitPile[i++].slice();
>>and trust that the Right Thing will be done.
> 
>   Ah! I think this is called "polymorphism".
> 
>   I wondered whether something like this could
>   also be formulated in Pascal.
> 
>   (Unintentionally, I return to the topic 
>   of the subject somewhat.)
> 
> PROGRAM ANIMALSOUNDS( OUTPUT );
> 
> TYPE
>    ANIMALTYPE =( DOG, CAT );
>   
>    ANIMAL = RECORD
>       ANIMALKIND: ANIMALTYPE;
>    END;
> 
> FUNCTION SOUND( ANIMAL: ANIMAL ): STRING;
> BEGIN
>    CASE ANIMAL.ANIMALKIND OF
>       DOG: SOUND := 'WOOF!';
>       CAT: SOUND := 'MEOW!';
>    END;
> END;
> 
> VAR MYDOG, MYCAT: ANIMAL;
> 
> BEGIN
>    MYDOG.ANIMALKIND := DOG;
>    MYCAT.ANIMALKIND := CAT;
>    WRITELN( 'IT SAYS: ', SOUND( MYDOG ));
>    WRITELN( 'IT SAYS: ', SOUND( MYCAT ));
> END.
> 
>   Output:
> 
> IT SAYS: WOOF!
> IT SAYS: MEOW!

It is well-know anty-pattern.  Theoretically it is equvalent
to OO way and may be the only way to implement given functionality
in a strongly-typed language.  But in practice OO way scales
better and is easier to modify.  In particular, this is toy
example and practical class at the beginning may look similar
to such a toy, but will grow together with the program.

-- 
                              Waldek Hebisch