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

New API and Syntax


Post New Thread Reply   
 
Thread Tools Display Modes
Mathias.
Veteran Member
Join Date: Aug 2010
Location: Canada is my city
Old 12-12-2014 , 13:22   Re: New API and Syntax
Reply With Quote #231

It might be, normally languages decide between this and self but both could be used. If it for personal code you are writing you can change it later if it used. I think bailopan reserve pretty much all of the keywords he will need.

Last edited by Mathias.; 12-12-2014 at 13:23. Reason: but power
Mathias. is offline
BAILOPAN
Join Date: Jan 2004
Old 12-12-2014 , 13:34   Re: New API and Syntax
Reply With Quote #232

Quote:
Originally Posted by Powerlord View Post
It seems to not like the "this" in these declarations as all the ones that have an arg named "this" are bombing with these types of messages:

C:\Projects\SourceMod\notepad++\sourcepawn.co mpiler\include\dhooks.inc(99) : error 010: invalid function or declaration

I know we're adding new keywords, but it's a Bad Thing (tm) to break existing code while doing that.
Indeed, this now a reserved keyword. Code that uses it outside of non-static methodmap contexts will have to find a new identifier. If dhooks has a public repository somewhere I can submit a patch to fix it.

I've done experiments to estimate how many plugins each new keyword breaks. It looks like my corpus did not include dhooks - and this was not a problem otherwise. So I'm pretty confident we can keep it.

For a keyword like this that is so critical to future plans, if it broke a large number of plugins, it could be made a "hybrid keyword" based on contextual usage. I'm going to have to do that for class since it's a very common identifier. That's really not a place we want to be in though, so I'll avoid it where I can.
__________________
egg

Last edited by BAILOPAN; 12-12-2014 at 13:36.
BAILOPAN is offline
WildCard65
Veteran Member
Join Date: Aug 2013
Location: Canada
Old 12-12-2014 , 15:29   Re: New API and Syntax
Reply With Quote #233

Quote:
Originally Posted by BAILOPAN View Post
Indeed, this now a reserved keyword. Code that uses it outside of non-static methodmap contexts will have to find a new identifier. If dhooks has a public repository somewhere I can submit a patch to fix it.

I've done experiments to estimate how many plugins each new keyword breaks. It looks like my corpus did not include dhooks - and this was not a problem otherwise. So I'm pretty confident we can keep it.

For a keyword like this that is so critical to future plans, if it broke a large number of plugins, it could be made a "hybrid keyword" based on contextual usage. I'm going to have to do that for class since it's a very common identifier. That's really not a place we want to be in though, so I'll avoid it where I can.
https://bitbucket.org/Drifter321/dhooks2
__________________
WildCard65 is offline
BAILOPAN
Join Date: Jan 2004
Old 12-12-2014 , 15:32   Re: New API and Syntax
Reply With Quote #234

Hi All,

I have added another feature to the transitional syntax. You can now place static methods on methodmaps, which can be invoked using the methodmap's type. For example,

PHP Code:
int gNumCrabs 0;

methodmap Crab
{
  public static 
int NextCrab() {
    return ++
gNumCrabs;
  }
}

int crab Crab.NextCrab(); 
This feature required a subtle change to how methodmaps are defined. Long story short, a methodmap now introduces a special type symbol, which means you cannot use a methodmap enum as an enum struct.
__________________
egg
BAILOPAN is offline
Mathias.
Veteran Member
Join Date: Aug 2010
Location: Canada is my city
Old 12-12-2014 , 16:27   Re: New API and Syntax
Reply With Quote #235

so what the difference between a methodmap static method and a non static one?
Mathias. is offline
BAILOPAN
Join Date: Jan 2004
Old 12-12-2014 , 16:33   Re: New API and Syntax
Reply With Quote #236

Good question. Say you have a methodmap of type T. Normal "instance" methods require an instance/variable of type T. A static method does not - it does not have a this value and must be invoked directly off T itself.

They have a lot of uses but the primary motivation here was to add a helper method to TopMenu. I'm sure more will come
__________________
egg

Last edited by BAILOPAN; 12-12-2014 at 16:34.
BAILOPAN is offline
WildCard65
Veteran Member
Join Date: Aug 2013
Location: Canada
Old 12-12-2014 , 17:06   Re: New API and Syntax
Reply With Quote #237

Will generics be introduced like C# and Java's <>
__________________
WildCard65 is offline
Powerlord
AlliedModders Donor
Join Date: Jun 2008
Location: Seduce Me!
Old 12-12-2014 , 17:25   Re: New API and Syntax
Reply With Quote #238

Quote:
Originally Posted by BAILOPAN View Post
Hi All,

I have added another feature to the transitional syntax. You can now place static methods on methodmaps, which can be invoked using the methodmap's type. For example,

PHP Code:
int gNumCrabs 0;

methodmap Crab
{
  public static 
int NextCrab() {
    return ++
gNumCrabs;
  }
}

int crab Crab.NextCrab(); 
This feature required a subtle change to how methodmaps are defined. Long story short, a methodmap now introduces a special type symbol, which means you cannot use a methodmap enum as an enum struct.
This would make Pred* very happy.
__________________
Not currently working on SourceMod plugin development.
Powerlord is offline
BAILOPAN
Join Date: Jan 2004
Old 12-12-2014 , 17:38   Re: New API and Syntax
Reply With Quote #239

Quote:
Originally Posted by WildCard65 View Post
Will generics be introduced like C# and Java's <>
It's not on my roadmap - there's enough to do before we need them.
__________________
egg
BAILOPAN is offline
ClassicGuzzi
Veteran Member
Join Date: Oct 2013
Location: Argentina
Old 12-12-2014 , 21:04   Re: New API and Syntax
Reply With Quote #240

I don't know if I'm supposed to ask here, I really like the new api/syntax and I want to start coding with it, but I need to know how much should it take for 1.7 to become the stable branch for sourcemod?
Also will a 1.7-complied plugin work on a server with sourcemod 1.6.X ?
Does the webcompiler work for 1.7 code?

Sorry for my noobs questions
ClassicGuzzi 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 11:24.


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