What is this feature called?

75 views
Skip to first unread message

Pier Bover

unread,
Apr 7, 2014, 1:08:44 AM4/7/14
to haxe...@googlegroups.com
In this example there's a static function called rect() that accepts a Sprite as the first parameter, but instead of being called rect(mySprite, parameters) it's called mySprite.rect(parameters).

Is this right?
Is there some documentation that explains this feature?

Greg Dove

unread,
Apr 7, 2014, 1:12:17 AM4/7/14
to haxe...@googlegroups.com
Sounds like using: http://haxe.org/manual/using

Greg Dove
Dove Software Development Ltd
http://greg-dove.com


--
To post to this group haxe...@googlegroups.com
http://groups.google.com/group/haxelang?hl=en
---
You received this message because you are subscribed to the Google Groups "Haxe" group.
For more options, visit https://groups.google.com/d/optout.

Pier Bover

unread,
Apr 7, 2014, 1:16:20 AM4/7/14
to haxe...@googlegroups.com
Thanks!

Is this unique to Haxe?


You received this message because you are subscribed to a topic in the Google Groups "Haxe" group.

For more options, visit https://groups.google.com/d/optout.



--
Pier Bover
y...@pierbover.com

Dan Korostelev

unread,
Apr 7, 2014, 3:10:59 AM4/7/14
to haxe...@googlegroups.com, y...@pierbover.com
I believe C# also has this feature, however the static functions must have explicit "this" modifier for their first argument.

понедельник, 7 апреля 2014 г., 9:16:20 UTC+4 пользователь Pier Bover написал:

sergey miryanov

unread,
Apr 7, 2014, 3:17:35 AM4/7/14
to haxe...@googlegroups.com
In C# this feature called extension methods.

Justin L Mills

unread,
Apr 7, 2014, 7:39:26 AM4/7/14
to haxe...@googlegroups.com
Also worth reading

http://scwn.net/2009/05/23/injecting-methods-into-haxe-classes-with-using/


Pier Bover:
> Thanks!
>
> Is this unique to Haxe?
>
>
> On Mon, Apr 7, 2014 at 12:12 AM, Greg Dove <greg...@gmail.com> wrote:
>
>> Sounds like using: http://haxe.org/manual/using
>>
>> Greg Dove
>> Dove Software Development Ltd
>> http://greg-dove.com
>>
>>
>> On Mon, Apr 7, 2014 at 5:08 PM, Pier Bover <pierb...@gmail.com> wrote:
>>
>>> In this example <http://haxe.org/doc/advanced/haxewithexteralc?lang=en> there's

Simon Krajewski

unread,
Apr 7, 2014, 7:50:28 AM4/7/14
to haxe...@googlegroups.com
Am 07.04.2014 13:39, schrieb Justin L Mills:
> Also worth reading
>
> http://scwn.net/2009/05/23/injecting-methods-into-haxe-classes-with-using/
>

The term "injecting" is misleading because it suggests modification.
Static extensions are syntactical and transform `e.f(a)` to `C.f(e, a)`
where f is a field name and C is the class containing this field. It
might appear to the user that the method has been "injected" in some way
because it is used like any real class method, but this makes matters
more confusing when thinking about "injecting" a method into a different
kind of type, such as a function.

Simon

Juraj Kirchheim

unread,
Apr 7, 2014, 8:21:36 AM4/7/14
to haxe...@googlegroups.com
It's settled:"method adjection" ;)
Reply all
Reply to author
Forward
0 new messages