<HTML><BODY>I'm making something like ORM. ORM class has methods `read' and `write' (implements interface orm<%>). But ORM class may have as a super either ORM class or simple class. <br><br>And here I have a problem, that simple class doesn't implement interface orm<%>, so I have to introduce new methods, <br>but if superclass is ORM class, then I have to override.<br><br>Another example is a mixin. Suppose I have an interface printable<%> = (interface () print)) and I want to make a mixin printable, that should make any class to implement printable.<br>The only solution is:<br><br>(define (printable %)<br> (if (method-in-interface? 'print (class->interface %))<br> %<br> ((mixin () (print) (define (print) (displayln this))) %)))<br><br><br>Sat, 24 May 2014 10:25:53 +0200 от Laurent <laurent.orseau@gmail.com>:<br>
<blockquote style="margin: 10px; padding: 0px 0px 0px 10px; border-left-color: rgb(8, 87, 166); border-left-width: 1px; border-left-style: solid;">
<div>
<div class="js-helper js-readmsg-msg">
<style type="text/css"></style>
<div>
<base href="https://e.mail.ru/" target="_self">
<div id="style_14009199740000000501_BODY"><div dir="ltr"><div><div><div>Hi Roman, <br><br></div><div>Out of curiosity:<br></div>I'm having difficulties finding a case where that would be necessary, unless when using an object there is a check to see if its class has the method or not, or if the class system does that itself and does nothing in case the method does not exist (instead of raising an exception).<br>
IMHO this would be better implemented with a void method in the parent class that can be overridden, or by implementing interfaces and check if the object is of one interface or the other. Override-or-declare doesn't strike me as good OO design (but if C++ does it, maybe there's a good reason).<br>
</div>Could you give a simple use case?<br><br></div>Laurent<br></div><div><br><br><div>On Sat, May 24, 2014 at 8:16 AM, Roman Klochkov <span dir="ltr"><<a href="//e.mail.ru/compose/?mailto=mailto%3akalimehtar@mail.ru" target="_blank">kalimehtar@mail.ru</a>></span> wrote:<br>
<blockquote style="margin: 0px 0px 0px 0.8ex; padding-left: 1ex; border-left-color: rgb(204, 204, 204); border-left-width: 1px; border-left-style: solid;">
<div>Is there a way to make C++ way inheritance: if superclass has the method, then override, else create new?<br><br>I see in manual, that public requires " method must not be present already in the superclass" and override requires "definition already present in the superclass".<br>
<br>Is it possible to not restrict the superclass?<span><font color="#888888"><br><br><br>-- <br>Roman Klochkov</font></span></div>
<br>____________________<br>
Racket Users list:<br>
<a href="http://lists.racket-lang.org/users" target="_blank">http://lists.racket-lang.org/users</a><br>
<br></blockquote></div><br></div>
</div>
<base href="https://e.mail.ru/" target="_self">
</div>
</div>
</div>
</blockquote>
<br>
<br>-- <br>Roman Klochkov<br></BODY></HTML>