[Y-devel] Slider widget done

Jerome Laheurte jerome at gandalf.fraca7.homeunix.net
Wed Mar 10 19:05:17 GMT 2004


On Wed, 10 Mar 2004, Andrew Suffield wrote:

> On Wed, Mar 10, 2004 at 06:19:23PM +0100, Jerome Laheurte wrote:
>
> > Yes, I do. In most situations though, it requires an explicit cast,
> > depending on the compiler's willingness, because it's obviously done
> > using operator overloading, so it becomes something like
> >
> >    printf("%s\n", (const char*)obj->text);
> >
> > (gcc will issue a warning without the cast, anyway)
>
> Ye gads, that is totally not how you do a static cast in C++. But that
> hardly matters; it's not a sane interface. That'll block for an entire
> round-trip, which is no good.

Okay, maybe my poor english or lack of CS formation is guilty, but I
don't know what you mean here (the "round-trip" stuff, not the cast.
I'm aware of static_cast<...>(), const_cast<...>() and I think
they're just other annoyances of C++, in most of the cases).

> > > > There's also a 'IntegerProperty' class, of course.
> > >
> > > Templates, damn you. That's what they're for.
> >
> > Well, I first tried with templates, but I let it go because I'm not
> > aware of a way to specify a "transformation function" in a template
> > (for instance, atol(3) in the case of integer properties).
>
> Template specialisation. It's not exactly high-level stuff.

How do you specialize a template on an actual value, instead of a
type? I'd really like to know, if it's feasible.

To make myself clear, I need to have a <class T, whatever> template in
which the

operator T ()

method will do

return foobar(whatever(value))

where 'whatever' should be

* identity (string property)
* atol() (integer property)

> > I choose this approach instead of a more traditionnal get/set method
> > pair because
> >
> > 1) I'm too used to Python :)
> >
> > 2) That's what's being done elsewhere (in Borland C++ Builder through
> > proprietary extensions to C++, and in Qt 3.x through a method I don't
> > know but which is probably very similar to mine).
>
> Which might make sense if it were a get/set pair, but it isn't. Reads
> are a two-step process. libYc++ does not pretend to be a remote object
> system.

Once again, I don't understand this 'two-step process' thing. Would
you care to explain, please ?

-- 
Jérôme Laheurte <fraca7 at free.fr>
"A University without students is like an ointment without a fly."
        -- Ed Nather, professor of astronomy at UT Austin



More information about the Y-devel mailing list









2026 © www.Y-Windows.Org - All Rights Reserved