[Gambas-user] Inheriting Stream in a Gambas class?

Benoît Minisini gambas at ...1...
Tue Jul 29 15:34:12 CEST 2014


Le 29/07/2014 15:24, Tobias Boege a écrit :
> On Tue, 29 Jul 2014, Beno?t Minisini wrote:
>> Le 29/07/2014 12:46, Tobias Boege a ?crit :
>>> Hi Benoit,
>>>
>>> is there currently the possibility to "Inherits Stream" in a class written
>>> in Gambas, so that it can be used as a Stream? If not, is it a goal for
>>> Gambas 4?
>>
>> It should be possible, did you try?
>>
>
> I didn't know what to do. I wrote
>
>    Inherits Stream
>
> into my class and then hesitated: I could instantiate the class but a
>
>    Print #myObject, "test"
>
> failed, of course, because my class has no methods related to Stream and I
> don't know where to put them, and what exactly.
>

Of course, it you want to create a new type of stream, you can't. This 
is internal to the interpreter. You can do that only in C/C++.

>>>
>>> Also re-read this mail substituting "Stream" by "the _convert and _operator
>>> interfaces seen in gb.gsl".
>>
>> for _convert, maybe. For _operator, I don't want, otherwise it will lead
>> to the C++ delirium with operator reimplementation.
>>
>
> I find this operator reimplementation thing very nifty in theory (just as
> function overloading ;-)). But I haven't seen that much C++ source code.
> Maybe they can turn it into hell. Well, there is a time and place for every
> concept, and I'm OK if Gambas isn't for these.

Same thing. You can implement _convert and _operator in C/C++ only, 
because that way I can prevent people doing dirty things more easily.

-- 
Benoît Minisini




More information about the User mailing list