[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: ObjC additions (Was: Re: PROPOSAL: Objective-C++)

From: Pascal Bourguignon
Subject: Re: ObjC additions (Was: Re: PROPOSAL: Objective-C++)
Date: Tue, 20 Nov 2001 00:17:29 +0100 (CET)

Stefan Urbanek <address@hidden> wrote:
> Me too. And, what also about literal objects like arrays or numbers?
>       ConstantArray *array = @array(@"Item 1", @"Item 2");
> or:
>       array = @(@"Item 1", @"Item 2");

I don't see the difference with:

   NSArray* array=[NSArray arrayWithObjects:@"Item 1",@"Item 2",0];
> And numbers:
>       ConstantNumber *value = @value(1);
> or
>       ConstantNumber *intValue    = @1;
>       ConstantNumber *doubleValue = @1.0;

or with:

   NSNumber* intValue=[NSNumber numberWithInteger:1];
   NSNumber* doubleValue=[NSNumber numberWithDouble:1.0];
> And even dictionaries:
>       ConstantDictionary *dict = @{@"Key" = @"Value"};

or with:

   NSDictionary* dict=[NSDictionary dictionaryWithObjectsAndKeys:

> Some default classes should be used like ConstantArray, ConstantNumber, and it
> should be redefined by some gcc option, like now there is
> -fconstant-string-class. Then, for example, ConstantNumber can be subclass of
> NSValue. Imagine, then you would be able to write:

The why don't you just use options such as:
    -DConstantString=NSString \
    -DConstantArray=NSArray \
    -DConstantDictionary=NSDictionary \

if you only want to write 

   ConstantDictionary* dict;

You could even add some macros such as:

#define BD [NSDictionary dictionaryWithObjectsAndKeys:
#define ED   ,0]

to be able to write:

   ConstantDictionary* dict = BD @"Key", @"Value" ED;

Ans similar for arrays, numbers, etc.

>       [dictionary setObject:@12.0 forValue:@"Size"];
> Just an idea. I think, it can be userful.
> What do you thing about it?

I don't think it's needed.

> How is it difficult to have something like this? 
> Stefan

A more useful idea would be to change the C preprocessor to be able to
handle variable number of parameters in macros. Just forget it.

__Pascal_Bourguignon__              (o_ Software patents are endangering
()  ASCII ribbon against html email //\ the computer industry all around
/\  and Microsoft attachments.      V_/ the world http://lpf.ai.mit.edu/
1962:DO20I=1.100  2001:my($f)=`fortune`;  http://petition.eurolinux.org/

Version: 3.1
GCS/IT d? s++:++(+++)>++ a C+++  UB+++L++++$S+X++++>$ P- L+++ E++ W++
N++ o-- K- w------ O- M++$ V PS+E++ Y++ PGP++ t+ 5? X+ R !tv b++(+)
DI+++ D++ G++ e+++ h+(++) r? y---? UF++++

reply via email to

[Prev in Thread] Current Thread [Next in Thread]