Hi Arjen,

>>
>> While I like the API simplification this could provide, I have two
>> primary concerns:
>>
>> First, could the first argument - the field to get/set - be an
>> enumerated type of some sort?  This should help catch typos at  
>> compile
>> time rather than run time. (PL_LINE_WIDTH rather than "line width").
>> Additional fields would then require adding elements to the
>> enumeration which, as I understand, should not break existing code.

Yes, enumeration of #define macros would be much better and faster.  
Comparing strings is surely not the best.
>>
>> Second, the void* approach may not translate well to other languages.
>> I'm not sure if there is a way to do this in C that would translate
>> well to the other PLplot-supported languages though.
>>
>
> I agree that a void * argument would be very bad for most languages,
> if not all, and it leaves the interpretation of the value up to the
> programmer. What about filling a structure instead?

Or even better an union. It's always problematic how such things  
should be solved, but I even have another idea. Why not get ALL  
information in one struct. e.g.

plgetattr( struct plAttributes* att);

struct plAttributes {
   int width;
   int frontcolor;
   int backcolor;
   ......
}

You will not use such functions in critical situations anyway (or?),  
so speed is not a problem and you could get all attributes at once. On  
the other side, maybe difficult to port to other functions, but  
something like structs or tables all languages have, or?

Just brainstorming,

Regards,
Werner



>
> Something like:
>
> type struct _plAttribute {
>     PLINT attributeType;  /* enumerated: integer, float,  
> boolean, ... */
>     PLINT intValue;       /* value reserved for attributes that can be
>                              represented as integers - at least in C  
> */
>     PLFLT floatValue;     /* ditto: floating point attributes */
>     char *stringValue;    /* ditto: character string attributes */
> } plAttribute;
>
> void plget( char *attribute, plAttribute *attValue );
> void plset( char *attribute, plAttribute *attValue );
>
> The various language bindings could then easily distinguish the
> proper type of the attribute (overloading the functions) or
> fill a similar structure and pass that.
>
> In C you could use the idiom:
>
> plget( "myattribute", &attValue );
> if ( attValue.attributeType == PL_ATT_INT ) {
>     attValue.intValue = newValue;
>     plset( "myattribute, &attValue );
> }
>
> so that you can be certain only a value of the proper type is passed.
>
> An alternative is:
>
> void plget( char *attribute, int *type, PLINT *intValue,
>      PLFLT *floatValue, char **stringValue );
> void plset( char *attribute, int type, PLINT intValue,
>      PLFLT floatValue, char *stringValue );
>
> with a similar associated idiom.
>
> Regards,
>
> Arjen
>
> ------------------------------------------------------------------------------
> Let Crystal Reports handle the reporting - Free Crystal Reports 2008  
> 30-Day
> trial. Simplify your report design, integration and deployment - and  
> focus on
> what you do best, core application coding. Discover what's new with
> Crystal Reports now.  http://p.sf.net/sfu/bobj-july
> _______________________________________________
> Plplot-devel mailing list
> Plplot-devel@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/plplot-devel


--
Dr. Werner Smekal
Institut fuer Allgemeine Physik
Technische Universitaet Wien
Wiedner Hauptstr 8-10
A-1040 Wien
Austria
DVR-Nr: 0005886

email: sme...@iap.tuwien.ac.at
web:   http://www.iap.tuwien.ac.at/~smekal
phone: +43-(0)1-58801-13463 (office)
        +43-(0)1-58801-13469 (laboratory)
fax:   +43-(0)1-58801-13499


------------------------------------------------------------------------------
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day 
trial. Simplify your report design, integration and deployment - and focus on 
what you do best, core application coding. Discover what's new with 
Crystal Reports now.  http://p.sf.net/sfu/bobj-july
_______________________________________________
Plplot-devel mailing list
Plplot-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/plplot-devel

Reply via email to