May 14, 2005 Shift of paradigms | ||||
|---|---|---|---|---|
| ||||
Posted in reply to Derek Parnell | Initially I was using this approach
but stopped for many reasons.
What could be done instead of "pseudo-member function"
(I am calling them: "external methods") ?
Let's say I would like to have "pseudo-member function" for wchar[] type
bool wchar[].like(wchar[] pattern) { .... }
in Harmonia I've created special wrapper
struct string
{
wchar[] chars;
static opCall(wchar[] s) { string s; s.chars = s; return s; }
bool like(wchar[] pattern) { .... }
}
Having this I am doing following when I need 'like'
ubyte[] loadFromUrl( wchar[] s )
{
if( string(s).like("file://*") )
.....
}
So I am not using 'string' as a type of variable but rather as a namespace designator. This shift of struct paradigm is a bit ugly (and probably less efficient a bit) but works.
This does not prevent to use string as a type of variable though.
But it does not allow you to have static variables of such strings....
(no ctors in structs!)
I am using string as a typename in harmonia.ui.controls.behaviors.LineEditor as type of dynamic text buffer.
Andrew.
| |||
Copyright © 1999-2021 by the D Language Foundation
Permalink
Reply