May 26, 2005 Re: Some operators in D... | ||||
---|---|---|---|---|
| ||||
Posted in reply to Sam |
> Recap of what I propose:
>
> Get rid of: 'null', 'true', 'false', '!', '!==', 'is'
> Add: 'not', 'isnull', 'nullify', 'truthify', 'falsify'
>
Sorry, doesn't get my vote (not that this is a democracy :) - I don't like that syntax at all.
Brad
|
May 26, 2005 Re: Some operators in D... | ||||
---|---|---|---|---|
| ||||
Posted in reply to Brad Beveridge | THAT'S IT!! I have it with all of these keywords!!!! I'm coming up with MY OWN language called: E() In article <d754a6$2tpu$1@digitaldaemon.com>, Brad Beveridge says... > > >> Recap of what I propose: >> >> Get rid of: 'null', 'true', 'false', '!', '!==', 'is' >> Add: 'not', 'isnull', 'nullify', 'truthify', 'falsify' >> > >Sorry, doesn't get my vote (not that this is a democracy :) - I don't like that syntax at all. > >Brad |
May 26, 2005 Re: Some operators in D... | ||||
---|---|---|---|---|
| ||||
Posted in reply to Sam | Sam wrote:
> Ok then why not put 'isnull' and 'nullify' into a namespace or make them
> built-in?
>
> Then:
>
> if(isnull(a))
> ..
> else
> nullify(a);
>
> Granted it's not as small as the syntax with 'is' and 'null', but this
> eliminates the need for 'is' and 'null'.
> You see, to me my way is simpler:
>
> if(isnull(a)) // 1 isnull method, 1 argument
> if(a is null) // 1 is operator, 2 arguments (1 special keyword)
>
> nullify(a) // 1 method, 1 argument
> a = null // 1 operator, 2 arguments (1 special keyword)
>
> if(!isnull(a)) // 1 ! operator, 1 isnull method, 1 argument
> if(a !== null) // 1 !== operator, 2 arguments (1 special keyword)
>
>
> I am for a 'not' keyword though!! It's better than this '!' that carried over
> from c++!
>
> Recap of what I propose:
>
> Get rid of: 'null', 'true', 'false', '!', '!==', 'is'
> Add: 'not', 'isnull', 'nullify', 'truthify', 'falsify'
>
> ;-D
>
Sorry, doesn't get my vote.
Note that this is NOT Java, D is a systems programming language, not a scripting language or smalltalk. (note: I'm not implying that java is a scripting language)
BUT ...
You can always write the functions yourself ..
bool isnull( void *p )
{
return (p is null);
}
void nullify(out void *p)
{
p = null;
}
What's the problem with that? Why don't you write that yourself and stop using null if you don't like it?
|
May 26, 2005 Re: Some operators in D... | ||||
---|---|---|---|---|
| ||||
Posted in reply to Hasan Aljudy | But see you've already gotten in trouble with the 'null' keyword! You can't do: a = null; or if(a == null) So as you see, it just spreads confusion! C++ is a systems language and it had no 'null' keyword, and nobody complained! Some defined their own null constant. I know D isn't C++ either, but if you're trying to invent the perfect language, the perfect language at least in my opinion wouldn't have the 'null' keyword. I know C# and java have 'true', 'false', and 'null' keywords but I truly believe that they added them in purely for show and to make their languages look nice. cout << null; // Exception! In article <d755f4$2usp$1@digitaldaemon.com>, Hasan Aljudy says... > >Sorry, doesn't get my vote. >Note that this is NOT Java, D is a systems programming language, not a >scripting language or smalltalk. (note: I'm not implying that java is a >scripting language) > >BUT ... > >You can always write the functions yourself .. > >bool isnull( void *p ) >{ > return (p is null); >} > >void nullify(out void *p) >{ > p = null; >} > >What's the problem with that? Why don't you write that yourself and stop using null if you don't like it? |
May 26, 2005 Re: Some operators in D... | ||||
---|---|---|---|---|
| ||||
Posted in reply to Sam | Sam wrote: > But see you've already gotten in trouble with the 'null' keyword! > > You can't do: > > a = null; No ? Why ? > I know C# and java have 'true', 'false', and 'null' keywords but I truly believe > that they added them in purely for show and to make their languages look nice. Ok, you asked for it... Here it comes... WTF ?! > cout << null; // Exception! Exception ? It's C++. If null was #define'd to 0, it would print... "0", not raise an exception... -- Tomasz Stachowiak /+ a.k.a. h3r3tic +/ |
May 26, 2005 Re: Some operators in D... | ||||
---|---|---|---|---|
| ||||
Posted in reply to Sam | Sam wrote: > But see you've already gotten in trouble with the 'null' keyword! > > You can't do: > > a = null; > > or > > if(a == null) Where is the trouble if you are wrapping it? of course you HAVE to use it inside the function that wraps it .. what else would you expect? > > So as you see, it just spreads confusion! I don't see that. Where is the confusion? remember, you're probably the one who's gonna use "isnull" and "nullify" :P > > C++ is a systems language and it had no 'null' keyword, and nobody complained! > Some defined their own null constant. heh .. so are you saying D shouldn't have a 0? I know you're not saying that, but if %99 percent of the people will define an alias for 'null' to zero, then what's the point? The only way we could do what you want is to remove 0 alltogether. > > I know D isn't C++ either, but if you're trying to invent the perfect language, > the perfect language at least in my opinion wouldn't have the 'null' keyword. Why? huh? Why? just because /you/ don't like it? > > I know C# and java have 'true', 'false', and 'null' keywords but I truly believe > that they added them in purely for show and to make their languages look nice. I don't know about C#, but in Java, true and false are not aliases for 0 and 1. 0 and 1 are integers, true and false are booleans, you CANNOT implicitly convert ints to booleans in Java. So it's not just for the language to look nice .. it's *strong* typing. Also, null in java is *NOT* an alias for 0, infact, you can't compare references against null. [Java code:] Object x; //x is a reference, not an object if( x == 0 ) //compiler error: x is not an int. ..... [/Java code] > cout << null; // Exception! what the other guy said .. << is overloaded (I assume) for different types, so it's not like << expects objects. when you pass a null, it's not a null pointer, it's a 0 integer. > > In article <d755f4$2usp$1@digitaldaemon.com>, Hasan Aljudy says... > >>Sorry, doesn't get my vote. >>Note that this is NOT Java, D is a systems programming language, not a scripting language or smalltalk. (note: I'm not implying that java is a scripting language) >> >>BUT ... >> >>You can always write the functions yourself .. >> >>bool isnull( void *p ) >>{ >> return (p is null); >>} >> >>void nullify(out void *p) >>{ >> p = null; >>} >> >>What's the problem with that? Why don't you write that yourself and stop using null if you don't like it? > > > |
May 26, 2005 Re: Some operators in D... | ||||
---|---|---|---|---|
| ||||
Posted in reply to Hasan Aljudy | ouch, typo:
I wrote:
> Also, null in java is *NOT* an alias for 0, infact, you can't compare references against null.
I meant: "you can't compare references against 0"
|
May 27, 2005 Re: Some operators in D... | ||||
---|---|---|---|---|
| ||||
Posted in reply to Sam | Sam wrote: > Recap of what I propose: > > Get rid of: 'null', 'true', 'false', '!', '!==', 'is' > Add: 'not', 'isnull', 'nullify', 'truthify', 'falsify' > The less keywords a language has, the simpler it bacomes and the easier it is to > learn. So you propose a removal of 4 simple and short keywords and two operators and want to add 5 new keywords, some of which I'd wonder if are valid English words at all. That will make the language definitely easier to learn! What's next ? Are you gonna tell us to remove char, wchar and dchar because they are sooooo redundant and then suggest adding char8859_1, char8859_2, char8859_3, charXXX, etc ? :\ -- Tomasz Stachowiak /+ a.k.a. h3r3tic +/ |
Copyright © 1999-2021 by the D Language Foundation