Raised This Month: $12 Target: $400
 3% 

New API and Syntax


Post New Thread Reply   
 
Thread Tools Display Modes
Merudo
Senior Member
Join Date: Feb 2016
Old 02-19-2016 , 19:04   Re: New API and Syntax
Reply With Quote #701

A quick question:

With the new syntax, how do I declare an array of vector, or an array of chars, when the first dimension is known but not the second?

Something like

Code:
new const String:mystrings[2][] =
{
"tiny_string", "a_very_very_large_string"
};
Neither of these work:

Code:
const char[2][] mystrings
const char[] mystrings[2]
const char mystrings[2][]

Last edited by Merudo; 02-19-2016 at 19:13.
Merudo is offline
Potato Uno
Veteran Member
Join Date: Jan 2014
Location: Atlanta, Georgia
Old 02-19-2016 , 19:54   Re: New API and Syntax
Reply With Quote #702

https://bugs.alliedmods.net/show_bug.cgi?id=6326
Potato Uno is offline
Merudo
Senior Member
Join Date: Feb 2016
Old 02-23-2016 , 01:24   Re: New API and Syntax
Reply With Quote #703

So it's due to a bug, and no my lack of understanding of the new syntax. Good .

Also, would it be possible to get more information on the "delete" operator? Like, can it be used on null handles?
Merudo is offline
WildCard65
Veteran Member
Join Date: Aug 2013
Location: Canada
Old 02-23-2016 , 07:16   Re: New API and Syntax
Reply With Quote #704

Quote:
Originally Posted by Merudo View Post
So it's due to a bug, and no my lack of understanding of the new syntax. Good .

Also, would it be possible to get more information on the "delete" operator? Like, can it be used on null handles?
PHP Code:
 delete myHandle
translates into:
PHP Code:
CloseHandle(myHandle);
myHandle INVALID_HANDLE 

Last edited by WildCard65; 02-23-2016 at 07:16.
WildCard65 is offline
Merudo
Senior Member
Join Date: Feb 2016
Old 02-23-2016 , 11:08   Re: New API and Syntax
Reply With Quote #705

So it makes it INVALID_HANDLE instead of null?
Merudo is offline
asherkin
SourceMod Developer
Join Date: Aug 2009
Location: OnGameFrame()
Old 02-23-2016 , 11:09   Re: New API and Syntax
Reply With Quote #706

INVALID_HANDLE is null.
__________________
asherkin is offline
nergal
Veteran Member
Join Date: Apr 2012
Old 03-21-2016 , 21:52   Re: New API and Syntax
Reply With Quote #707

may I request that we be able to typedef more than just functions?

maybe even for variables and arrays like in C?

wink wink
PHP Code:
typedef float vec_t;
typedef vec_t vec3_t[3]; 
__________________

Last edited by nergal; 03-21-2016 at 21:53.
nergal is offline
BAILOPAN
Join Date: Jan 2004
Old 03-21-2016 , 23:21   Re: New API and Syntax
Reply With Quote #708

The compiler, internally, has no concept of a "type" aside from hacks like methodmaps that we've surgically bolted on. It's easy to map names ("float" -> "vec_t" for example), but mapping to an entirely new type is basically impossible in the existing codebase.
__________________
egg
BAILOPAN is offline
nergal
Veteran Member
Join Date: Apr 2012
Old 03-24-2016 , 01:17   Re: New API and Syntax
Reply With Quote #709

Quote:
Originally Posted by BAILOPAN View Post
The compiler, internally, has no concept of a "type" aside from hacks like methodmaps that we've surgically bolted on. It's easy to map names ("float" -> "vec_t" for example), but mapping to an entirely new type is basically impossible in the existing codebase.
then why not syntactically sugarcoat typedef so it achieves that desired effect?

why not do "typedef float vec_t[3];", so I can code "vec_t origin;", but inside the compiler/under the hood, it'll become "float origin[3];" ?

This would also save you guys from having to create a vector object in general for vectors.
__________________

Last edited by nergal; 03-24-2016 at 09:36.
nergal is offline
BAILOPAN
Join Date: Jan 2004
Old 03-25-2016 , 14:42   Re: New API and Syntax
Reply With Quote #710

That doesn't really change how it would be implemented. The best we could do is some kind of hook in the typename parser that has a table of alternate tokens to return. That might be an option, actually, but I'll have to think about it.
__________________
egg
BAILOPAN is offline
Reply


Thread Tools
Display Modes

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 07:25.


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