realbasic-nug
[Top] [All Lists]

Re: BinaryStream as superclass

To: REALbasic NUG <realbasic-nug@lists.realsoftware.com>
Subject: Re: BinaryStream as superclass
From: Joe Strout <joe@inspiringapps.com>
Date: Mon, 27 Apr 2009 08:35:50 -0600
Authentication-results: mx.google.com; spf=neutral (google.com: 74.124.194.228 is neither permitted nor denied by best guess record for domain of realbasic-nug-bounces@lists.realsoftware.com) smtp.mail=realbasic-nug-bounces@lists.realsoftware.com
Delivered-to: listarchive@realsoftware.com
In-reply-to: <49f5b139.389.1568e.2063416559@ml3.myemail.com>
Organization: Inspiring Applications, Inc.
References: <49f5b139.389.1568e.2063416559@ml3.myemail.com>
Reply-to: REALbasic NUG <realbasic-nug@lists.realsoftware.com>
Sender: realbasic-nug-bounces@lists.realsoftware.com
User-agent: Thunderbird 2.0.0.21 (Macintosh/20090302)
realnug@the-gamesters.co.uk wrote:

Having created classes to extend things like the TCPsocket
with no problem, I thought do the same when I wanted to add
functions to a BinaryStream.

Basically I have a class (eg myStream) which has a
superclass of Binarystream.

That's fine, as long as you're going to instantiate myStream yourself somehow -- for example, by giving it a constructor that takes a string, and having that call through to the BinaryStream constructor that takes a string.

I then define a stream using MyStream, but  when I try to
open a file with OpenAsBinaryFile, I get a Type mismatch
error. Saying expected MyStream but got BinaryStream.

And it's quite right. OpenAsBinaryFile returns a BinaryStream, not a MyStream. You can't change what type some framework function returns.

The only difference I could see is that TCPsocket needs to
be added to the form (initially), as it is a superclass of
SocketCore.

No, the difference is that you're instantiating the socket yourself, not calling some function that returns a TCPSocket. If you did, you'd find that it still returns a TCPSocket, not some subclass you may be thinking of.

Yes, I could just write the additional functions I need
separately, but this seemed the neatest solution. Any
thoughts?

Probably a module of Extends methods are the best solution in practice.

Best,
- Joe


--
Joe Strout
Inspiring Applications, Inc.
http://www.InspiringApps.com


_______________________________________________
Unsubscribe or switch delivery mode:
<http://www.realsoftware.com/support/listmanager/>

Search the archives:
<http://support.realsoftware.com/listarchives/lists.html>


<Prev in Thread] Current Thread [Next in Thread>
  • Re: BinaryStream as superclass, Joe Strout <=