Raised This Month: $32 Target: $400
 8% 

New API and Syntax


Post New Thread Reply   
 
Thread Tools Display Modes
VoiDeD
AlliedModders Donor
Join Date: Mar 2009
Location: Illinois, USA
Old 07-14-2014 , 10:43   Re: New API and Syntax
Reply With Quote #21

Quote:
Originally Posted by WildCard65 View Post
I highly doubt that old scripts can compile on SM 1.7 atm...
See: https://travis-ci.org/50DKP/FF2-Official
But other then that, taking a look at method maps documentation link, they are REALLY AWESOME! Much neater then current system as it actually makes things easier to understand.
Try to reduce your problem to the simplest test case and file a bug.
__________________
VoiDeD is offline
TheWho
AlliedModders Donor
Join Date: Jul 2012
Old 07-14-2014 , 18:58   Re: New API and Syntax
Reply With Quote #22

Again a milestone for every developer, nice!
TheWho is offline
LambdaLambda
AlliedModders Donor
Join Date: Oct 2010
Location: London
Old 07-14-2014 , 21:51   Re: New API and Syntax
Reply With Quote #23

Hate me, but I loved SP for it's syntax.
LambdaLambda is offline
BAILOPAN
Join Date: Jan 2004
Old 07-14-2014 , 23:00   Re: New API and Syntax
Reply With Quote #24

Quote:
Originally Posted by LambdaLambda View Post
Hate me, but I loved SP for it's syntax.
I think you'll find the syntax much more fluid after using it for a bit. The lack of colons everywhere lowers code density. I do realize "new" had a very typeless feel to it that gets lost with "int". I think we'll be able to solve that eventually though.
__________________
egg

Last edited by BAILOPAN; 07-14-2014 at 23:01.
BAILOPAN is offline
Thrawn2
Veteran Member
Join Date: Apr 2009
Old 07-16-2014 , 12:32   Re: New API and Syntax
Reply With Quote #25

I've adapted the smjansson includes and test plugin to the new syntax to see how it feels. Here
This was quite easy and i'm really pleased with the new syntax. Good job!

Have one question though: How to deal with e.g. INVALID_HANDLE checks? Cast (i.e. tag) the methodmap as a Handle before comparison?
__________________
einmal mit profis arbeiten. einmal.
Thrawn2 is offline
splewis
Veteran Member
Join Date: Feb 2014
Location: United States
Old 07-16-2014 , 13:25   Re: New API and Syntax
Reply With Quote #26

Looks awesome. Can't wait to give it a spin!
__________________
splewis is offline
BAILOPAN
Join Date: Jan 2004
Old 07-16-2014 , 13:57   Re: New API and Syntax
Reply With Quote #27

Quote:
Originally Posted by Thrawn2 View Post
I've adapted the smjansson includes and test plugin to the new syntax to see how it feels. Here
This was quite easy and i'm really pleased with the new syntax. Good job!

Have one question though: How to deal with e.g. INVALID_HANDLE checks? Cast (i.e. tag) the methodmap as a Handle before comparison?
I forgot to mention it in the first post, but there's a new constant you can use, null, which is way easier to type. It should cast to any Handles or anything inheriting from Handle. INVALID_HANDLE should work too though if you still want to use it - if it doesn't, send me the code and I can take a look.
__________________
egg
BAILOPAN is offline
Thrawn2
Veteran Member
Join Date: Apr 2009
Old 07-17-2014 , 12:54   Re: New API and Syntax
Reply With Quote #28

Quote:
Originally Posted by BAILOPAN View Post
I forgot to mention it in the first post, but there's a new constant you can use, null, which is way easier to type. It should cast to any Handles or anything inheriting from Handle. INVALID_HANDLE should work too though if you still want to use it - if it doesn't, send me the code and I can take a look.
Neat.

Using INVALID_HANDLE does work if I cast the methodmap to a Handle first, null on the other hand does only work if i cast it to the corresponding object type.

E.g. this does not work unless the comparison is: f != StringMap:null
Code:
#include <sourcemod>

public OnPluginStart() {
	StringMap f = StringMap();

	LogMessage("StringMap is not null? %d", f != null);
}
Without the cast it results in:
sm17.test.sp(6) : error 132: cannot coerce non-object type StringMap to object type null_t

Is there a way to avoid tagging of null or the other value altogether?

Also more questions if you don't mind:
  • "any", while quite hacky was also quite useful. E.g. the old tests include used by smjansson had a method Tests_Is(any:a, any:b) which compared a to b. This worked with int, float, handle, i.e. you could throw anything at it. How would one specify an any: parameter in the new syntax?
  • Will there be the possibility to define multiple constructors with a different set of parameters?
  • When exactly is the destructor being called? When I delete the object and before the "old" CloseHandle is being performed?

And one bug report: it is possible to crash the compiler by using delete instead of CloseHandle.
It is easily reproducible by changing line 1013 of the previously linked smjansson include to use delete and trying to compile the test plugin that comes with it. Sorry for not having a smaller and more specific testcase for this.

Thanks!

Edit: The wiki says:
Quote:
Currently only "get" accessors are available.
Is this accurate? The menus include is using property setters.
__________________
einmal mit profis arbeiten. einmal.

Last edited by Thrawn2; 07-17-2014 at 13:04.
Thrawn2 is offline
BAILOPAN
Join Date: Jan 2004
Old 07-18-2014 , 00:53   Re: New API and Syntax
Reply With Quote #29

Quote:
Originally Posted by Thrawn2 View Post
E.g. this does not work unless the comparison is: f != StringMap:null
Good catch! This has been fixed on master.

Quote:
Originally Posted by Thrawn2 View Post
"any", while quite hacky was also quite useful. E.g. the old tests include used by smjansson had a method Tests_Is(any:a, any:b) which compared a to b. This worked with int, float, handle, i.e. you could throw anything at it. How would one specify an any: parameter in the new syntax?
The reason any is not available in the new syntax is fairly technical... the way it interacts with natives makes it impossible to do run-time type checking. It's verboten in the transitional syntax. On the other hand - it currently sees a lot of use and the replacements I have in mind (generics or top-type object) are nowhere near ready. I'll add any back on master for all but new-style natives.

Quote:
Originally Posted by Thrawn2 View Post
Will there be the possibility to define multiple constructors with a different set of parameters?
Overloading - yes! Eventually, I hope.

Quote:
Originally Posted by Thrawn2 View Post
When exactly is the destructor being called? When I delete the object and before the "old" CloseHandle is being performed?
delete is syntactic sugar for immediately invoking the destructor. That is, delete handle is equivalent to handle.~CloseHandle() (if that were valid syntax).

Quote:
Originally Posted by Thrawn2 View Post
Edit: The wiki says:
Is this accurate? The menus include is using property setters.
I've updated the wiki to reflect that setters are available.
__________________
egg

Last edited by BAILOPAN; 07-18-2014 at 01:08.
BAILOPAN is offline
ddhoward
Veteran Member
Join Date: May 2012
Location: California
Old 07-18-2014 , 01:37   Re: New API and Syntax
Reply With Quote #30

Quote:
All of the changes are opt-in, and old scripts will continue to compile.
Do you imagine this changing in the future? Once the 'transition' is complete, will these old scripts still function?
__________________
ddhoward 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 09:18.


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