Sign in to follow this  
Followers 0
Yashied

"nil" as keyword

32 posts in this topic




Not the right forum, Null sounds better, and why? 0 does (quite) the same job.

Chr(0) returns Null.

Share this post


Link to post
Share on other sites

The integer value of zero is a fine enough null. That's all null really is anyways. A pointer that points to nothing.

Share this post


Link to post
Share on other sites

#4 ·  Posted (edited)

"Nil" is not zero, this is zero pointer, so the code is much more logical reading.

$Res = DllCall(...)

if $Res[0] = nil then

...

endif

I think that it looks more correct than if $Res[0] = 0 then ... In fact present in AutoIt true and false keywords.

Edited by Yashied

Share this post


Link to post
Share on other sites

Nil could be seen as a substitute for @error and variable declaration. I can't say it helps making programming code more readable or less programs prone to crash.

Obviously this is not for AutoIt. I don't think anyone has to mention any reasons.

Share this post


Link to post
Share on other sites

It's "null" is it not?

James, what you are thinking of is technically nul not null. Common mistake. Look at Chr(0) in the ascii table

NULL is a macro defined in <stddef.h> for the null pointer.

NUL is the name of the first character in the ASCII character set.


George

Question about decompiling code? Read the decompiling FAQ and don't bother posting the question in the forums.

Be sure to read and follow the forum rules. -AKA the AutoIt Reading and Comprehension Skills test.***

The PCRE (Regular Expression) ToolKit for AutoIT - (Updated Oct 20, 2011 ver:3.0.1.13) - Please update your current version before filing any bug reports. The installer now includes both 32 and 64 bit versions. No change in version number.

Visit my Blog .. currently not active but it will soon be resplendent with news and views. Also please remove any links you may have to my website. it is soon to be closed and replaced with something else.

"Old age and treachery will always overcome youth and skill!"

Share this post


Link to post
Share on other sites

Zero and null are two different things. In AutoIt its more common to use "" in place of null.

Share this post


Link to post
Share on other sites

Zero and null are two different things. In AutoIt its more common to use "" in place of null.

I seem to recall that we just went down this path in another thread.

Also, some place in the mix the default keyword comes into play


George

Question about decompiling code? Read the decompiling FAQ and don't bother posting the question in the forums.

Be sure to read and follow the forum rules. -AKA the AutoIt Reading and Comprehension Skills test.***

The PCRE (Regular Expression) ToolKit for AutoIT - (Updated Oct 20, 2011 ver:3.0.1.13) - Please update your current version before filing any bug reports. The installer now includes both 32 and 64 bit versions. No change in version number.

Visit my Blog .. currently not active but it will soon be resplendent with news and views. Also please remove any links you may have to my website. it is soon to be closed and replaced with something else.

"Old age and treachery will always overcome youth and skill!"

Share this post


Link to post
Share on other sites

#10 ·  Posted (edited)

Most people in this forum use variables whose names facilitates understanding of the code ($hIcon, $tStruct, $sName, etc.). I propose only to extend this approach. If I write $a = nil, then it clearly indicates that the variable $a is a pointer. Technically, "nil" can equal zero (0).

Edited by Yashied

Share this post


Link to post
Share on other sites

Nil, nul, null, 0, zero, ... nothing.

I really have nothing (null) to do in this parts of the forum, but I know that keyword for null pointer would make some of the udf's to work fully as expected.

... if you do:

..., "str", "something", ...

then it's obvious (hey Valik) that if you want to pass null there you have to rewrite the func to be:

..., "ptr", 0, ...

or you could pass non-existing keyword null.


♡♡♡

.

eMyvnE

Share this post


Link to post
Share on other sites

Most people in this forum use variables whose names facilitates understanding of the code ($hIcon, $tStruct, $sName, etc.). I propose only to extend this approach. If I write $a = nil, then it clearly indicates that the variable $a is a pointer. Technically, "nil" can equal zero (0).

I think what you are wanting is really a feature request and as such belongs in TRAC

Be sure to check if it has already been requested and be sure to read the list of things NOT TO ASK FOR.


George

Question about decompiling code? Read the decompiling FAQ and don't bother posting the question in the forums.

Be sure to read and follow the forum rules. -AKA the AutoIt Reading and Comprehension Skills test.***

The PCRE (Regular Expression) ToolKit for AutoIT - (Updated Oct 20, 2011 ver:3.0.1.13) - Please update your current version before filing any bug reports. The installer now includes both 32 and 64 bit versions. No change in version number.

Visit my Blog .. currently not active but it will soon be resplendent with news and views. Also please remove any links you may have to my website. it is soon to be closed and replaced with something else.

"Old age and treachery will always overcome youth and skill!"

Share this post


Link to post
Share on other sites

Most people in this forum use variables whose names facilitates understanding of the code ($hIcon, $tStruct, $sName, etc.). I propose only to extend this approach. If I write $a = nil, then it clearly indicates that the variable $a is a pointer. Technically, "nil" can equal zero (0).

If you're using nil then you are referring to an invalid or uninitialized variable. Like Ruby or Lua.

Not a pointer.

Share this post


Link to post
Share on other sites

Default is AutoIt's uninitialized variable.

Share this post


Link to post
Share on other sites

Share this post


Link to post
Share on other sites

It's not going to happen. It's not needed. You want it? Guess what:

Global Const $Nil = 0

No, seriously. You're done.

What you are asking for simply does not make sense for this language. Other languages don't use nil, nul, null, none, nothing, et all for only syntax reasons. In most of those languages it implies a lack of object in that it doesn't have a type at all. We don't use that convention in AutoIt. Instead each various hidden type has a default value which means "empty". For pretty much all types it can be compared to 0.

Share this post


Link to post
Share on other sites

MJight be one to add to the "Things Not to Ask For" list?

Actually I thought it had already been refused at one time but I didn't find it on Trac, probably due to a poor search. I know the discussion has come up a few times.


George

Question about decompiling code? Read the decompiling FAQ and don't bother posting the question in the forums.

Be sure to read and follow the forum rules. -AKA the AutoIt Reading and Comprehension Skills test.***

The PCRE (Regular Expression) ToolKit for AutoIT - (Updated Oct 20, 2011 ver:3.0.1.13) - Please update your current version before filing any bug reports. The installer now includes both 32 and 64 bit versions. No change in version number.

Visit my Blog .. currently not active but it will soon be resplendent with news and views. Also please remove any links you may have to my website. it is soon to be closed and replaced with something else.

"Old age and treachery will always overcome youth and skill!"

Share this post


Link to post
Share on other sites

Nil and 0 is technically the same, but logically perceived differently (as 0 and False or 1 and True).

Not really.

nil + 5 = ...

Errors out. You can't perform arithmetic on nil values.

nil & " some string" = ...

Errors out too. You can not perform concatenation on nil values.

Share this post


Link to post
Share on other sites

Not really.

nil + 5 = ...

Errors out. You can't perform arithmetic on nil values.

nil & " some string" = ...

Errors out too. You can not perform concatenation on nil values.

Nil this is "empty" pointer (0x00000000). Nil + 5 = !!!?????

But the next record, I think is logical, but not quite correct in the context of AutoIt.

$t = DllStructCreate(...)

...

$t = Nil

Share this post


Link to post
Share on other sites

Nil this is "empty" pointer (0x00000000). Nil + 5 = !!!?????

But the next record, I think is logical, but not quite correct in the context of AutoIt.

$t = DllStructCreate(...)

...

$t = Nil

If you're using nil then you are referring to an invalid or uninitialized variable. Like Ruby or Lua.

Not a pointer.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0