Raised This Month: $ Target: $400
 0% 

New API and Syntax


Post New Thread Reply   
 
Thread Tools Display Modes
KissLick
Veteran Member
Join Date: Nov 2012
Location: void
Old 11-15-2014 , 14:30   Re: New API and Syntax
Reply With Quote #161

I have another question, will you "empty" handle variable on closing handle in new API?

like:
PHP Code:
new Handle:hndl INVALID_HANDLE;
hndl CreateArray();

/*
.
.
.
*/

CloseHandle(hndl); // hndl = INVALID_HANDLE 
Or at least add native to check handle validity like
PHP Code:
bool:IsHandleValid(Handle:hndl
KissLick is offline
BAILOPAN
Join Date: Jan 2004
Old 11-15-2014 , 14:35   Re: New API and Syntax
Reply With Quote #162

You can use delete on a null handle. For example,

PHP Code:
ArrayList array = CreateArray();
...
delete array; 
You can use CloseHandle on a null handle as well, but new-syntax prefers delete.
__________________
egg

Last edited by BAILOPAN; 11-15-2014 at 14:36.
BAILOPAN is offline
friagram
Veteran Member
Join Date: Sep 2012
Location: Silicon Valley
Old 11-15-2014 , 16:58   Re: New API and Syntax
Reply With Quote #163

Are we keeping the requirement for array declaration? It becomes pointless after 3 anyways
[] [][] [][][]

Isn't
new foo[2][2] essentially the same as new foo[2*2]
or new foo[3][1] and new foo[3]
__________________
Profile - Plugins
Add me on steam if you are seeking sp/map/model commissions.
friagram is offline
BAILOPAN
Join Date: Jan 2004
Old 11-15-2014 , 21:21   Re: New API and Syntax
Reply With Quote #164

@friagram: No, they are quite different. int[2][2] is a T[2] where T=int[2]. An int[2*2] is a T[4] where T=int.

It is true that you can use N*M cells to simulate coordinates of a 2d-array, but that does not make it an array of arrays, since arrays are a special builtin type.
__________________
egg
BAILOPAN is offline
friagram
Veteran Member
Join Date: Sep 2012
Location: Silicon Valley
Old 11-16-2014 , 06:49   Re: New API and Syntax
Reply With Quote #165

Aye

Oh, there are some weird preprocessor bugs, and also some dumb ones.

Not sure if this should be bothered with or not but a

#define HAMMER HAMMER Will stall the compiler forever

Also, if/elseif/endif skips the loose indentation warnings. Not sure if it is intentional.

Also, types in switches, is there a way around this double colon case problem? If I have something of an enum type that I cast like Blahtype:84 it won't play nice in a switch, i have to use the int without the tag. I suppose the new system will help with this.
__________________
Profile - Plugins
Add me on steam if you are seeking sp/map/model commissions.

Last edited by friagram; 11-16-2014 at 06:53.
friagram is offline
BAILOPAN
Join Date: Jan 2004
Old 11-16-2014 , 15:01   Re: New API and Syntax
Reply With Quote #166

@friagram - the preprocessor will be phased out over time, so I'm not as concerned about bugs in it (the recursion bug is known).

You can put the case in parenthesis, like this:
Code:
  case (BlahType:84):

Pawn should be taking the type of the switch() and checking it against each case. (If it's not, I can fix that for 1.7.) So, if you have to write code like above, it would seem that the initial switch() expression is incorrectly typed.
__________________
egg

Last edited by BAILOPAN; 11-16-2014 at 15:03.
BAILOPAN is offline
friagram
Veteran Member
Join Date: Sep 2012
Location: Silicon Valley
Old 11-16-2014 , 18:15   Re: New API and Syntax
Reply With Quote #167

Iirc the tf conds cause problems sometimes, like if i do

Switch(condition)

case TFCond_Taunting:
case TFCond:5:

So, if parenthesis around it works, that's fine. I could just use a 5 without the type, but its not always convenient for readability. Usually I just use the preprocessor to give the variable a friendly name and go back and fix it down the road I suppose I could make a static const of that type and name it something decent until the new conds get added in a later update, like static const TFCond:TFCond_Ubercharged = 5
__________________
Profile - Plugins
Add me on steam if you are seeking sp/map/model commissions.

Last edited by friagram; 11-16-2014 at 18:18.
friagram is offline
psychonic

BAFFLED
Join Date: May 2008
Old 11-16-2014 , 20:11   Re: New API and Syntax
Reply With Quote #168

Quote:
Originally Posted by friagram View Post
Iirc the tf conds cause problems sometimes, like if i do

Switch(condition)

case TFCond_Taunting:
case TFCond:5:

So, if parenthesis around it works, that's fine. I could just use a 5 without the type, but its not always convenient for readability. Usually I just use the preprocessor to give the variable a friendly name and go back and fix it down the road I suppose I could make a static const of that type and name it something decent until the new conds get added in a later update, like static const TFCond:TFCond_Ubercharged = 5
Why wouldn't you just always use the named value anyway rather than tagging the bare integer?
psychonic is offline
nergal
Veteran Member
Join Date: Apr 2012
Old 11-17-2014 , 00:43   Re: New API and Syntax
Reply With Quote #169

Question on the new Syntax+API.

Is there Classes and/or Data Structures?
If not, will there be in the future?
__________________
nergal is offline
BAILOPAN
Join Date: Jan 2004
Old 11-17-2014 , 01:02   Re: New API and Syntax
Reply With Quote #170

The first post answers this question. The syntax is a transitional, syntactic transformation. It does not introduce any new semantics. It's intended to pave the way for cleaning up code to make newer semantics possible.
__________________
egg

Last edited by BAILOPAN; 11-17-2014 at 01:03.
BAILOPAN is offline
Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 13:58.


Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Theme made by Freecode