Retrieve the local Imports from the inside of a macro (Context.getLocalImports())

classic Classic list List threaded Threaded
6 messages Options
Reply | Threaded
Open this post in threaded view
|

Retrieve the local Imports from the inside of a macro (Context.getLocalImports())

Heinz Hölzer-2
Hi Nicolas,

would it be possible to add a function like haxe.macro.Context.getLocalImports() or getLocalContextTypes() to the Context class? This method should return the Import Context in which an Expression is evaluated (maybe a list of types). Context.typeof already uses these types to determine the expression type.

You can read more about my usage scenario in this thread:

http://haxe.1354130.n2.nabble.com/New-haxe-stagging-nemerle-like-macro-available-on-github-td6954481.html

especially in this post

http://haxe.1354130.n2.nabble.com/template/NamlServlet.jtp?macro=print_post&node=6966421

best,
h

--
haXe - an open source web programming language
http://haxe.org
Reply | Threaded
Open this post in threaded view
|

Re: Retrieve the local Imports from the inside of a macro (Context.getLocalImports())

Juraj Kirchheim
+1. This would be very helpful. Also, it would be nice (although not
necessary) if one could add imports from a macro.

2011/11/5 Heinz Hölzer <[hidden email]>:

> Hi Nicolas,
>
> would it be possible to add a function like
> haxe.macro.Context.getLocalImports() or getLocalContextTypes() to the
> Context class? This method should return the Import Context in which an
> Expression is evaluated (maybe a list of types). Context.typeof already uses
> these types to determine the expression type.
>
> You can read more about my usage scenario in this thread:
>
> http://haxe.1354130.n2.nabble.com/New-haxe-stagging-nemerle-like-macro-available-on-github-td6954481.html
>
> especially in this post
>
> http://haxe.1354130.n2.nabble.com/template/NamlServlet.jtp?macro=print_post&node=6966421
>
> best,
> h
>
> --
> haXe - an open source web programming language
> http://haxe.org
>

--
haXe - an open source web programming language
http://haxe.org
Reply | Threaded
Open this post in threaded view
|

Re: Retrieve the local Imports from the inside of a macro (Context.getLocalImports())

Heinz Hölzer-2
Do you mean something like "import MyMacro.importMyTypes()"?

Am 05.11.2011 19:57, schrieb Juraj Kirchheim:

> +1. This would be very helpful. Also, it would be nice (although not
> necessary) if one could add imports from a macro.
>
> 2011/11/5 Heinz Hölzer<[hidden email]>:
>> Hi Nicolas,
>>
>> would it be possible to add a function like
>> haxe.macro.Context.getLocalImports() or getLocalContextTypes() to the
>> Context class? This method should return the Import Context in which an
>> Expression is evaluated (maybe a list of types). Context.typeof already uses
>> these types to determine the expression type.
>>
>> You can read more about my usage scenario in this thread:
>>
>> http://haxe.1354130.n2.nabble.com/New-haxe-stagging-nemerle-like-macro-available-on-github-td6954481.html
>>
>> especially in this post
>>
>> http://haxe.1354130.n2.nabble.com/template/NamlServlet.jtp?macro=print_post&node=6966421
>>
>> best,
>> h
>>
>> --
>> haXe - an open source web programming language
>> http://haxe.org
>>


--
haXe - an open source web programming language
http://haxe.org
Reply | Threaded
Open this post in threaded view
|

Re: Retrieve the local Imports from the inside of a macro (Context.getLocalImports())

Juraj Kirchheim
Actually, there's many ways to go about it. For the sake of
simplicity, it would probably be good enough if one could add an
import statement (or a using statement for that matter) to the current
module from any macro call. Of course this gives you a lot of rope to
hang yourself with, but so does Context.defineType. In either case,
IMHO the options outweigh the "risks".

As for calling a macro from within an import statement, I rather think
it might be a good idea to allow macro calls at top-level of a module.
So one could say Import.all(some.pkg) to achieve import some.pkg.* and
so forth. And it might make sense to just have top-level macro calls,
that use Context.defineType, that act as a custom complement to class
and enum declarations.


2011/11/5 Heinz Hölzer <[hidden email]>:

> Do you mean something like "import MyMacro.importMyTypes()"?
>
> Am 05.11.2011 19:57, schrieb Juraj Kirchheim:
>>
>> +1. This would be very helpful. Also, it would be nice (although not
>> necessary) if one could add imports from a macro.
>>
>> 2011/11/5 Heinz Hölzer<[hidden email]>:
>>>
>>> Hi Nicolas,
>>>
>>> would it be possible to add a function like
>>> haxe.macro.Context.getLocalImports() or getLocalContextTypes() to the
>>> Context class? This method should return the Import Context in which an
>>> Expression is evaluated (maybe a list of types). Context.typeof already
>>> uses
>>> these types to determine the expression type.
>>>
>>> You can read more about my usage scenario in this thread:
>>>
>>>
>>> http://haxe.1354130.n2.nabble.com/New-haxe-stagging-nemerle-like-macro-available-on-github-td6954481.html
>>>
>>> especially in this post
>>>
>>>
>>> http://haxe.1354130.n2.nabble.com/template/NamlServlet.jtp?macro=print_post&node=6966421
>>>
>>> best,
>>> h
>>>
>>> --
>>> haXe - an open source web programming language
>>> http://haxe.org
>>>
>
>
> --
> haXe - an open source web programming language
> http://haxe.org
>

--
haXe - an open source web programming language
http://haxe.org
Reply | Threaded
Open this post in threaded view
|

Re: Retrieve the local Imports from the inside of a macro (Context.getLocalImports())

sledorze
Almost related to the question:
Do one know if scoped imports are planned in haxe or not.
Reply | Threaded
Open this post in threaded view
|

Re: Retrieve the local Imports from the inside of a macro (Context.getLocalImports())

Heinz Hölzer-2
In reply to this post by Juraj Kirchheim
Calling from the toplevel would be nice, so that these macro could either return "imports", "usings", "types", "nothing" or arrays of them. 
By the way, there is already a discussion about this here: 



2011/11/5 Juraj Kirchheim <[hidden email]>
Actually, there's many ways to go about it. For the sake of
simplicity, it would probably be good enough if one could add an
import statement (or a using statement for that matter) to the current
module from any macro call. Of course this gives you a lot of rope to
hang yourself with, but so does Context.defineType. In either case,
IMHO the options outweigh the "risks".

As for calling a macro from within an import statement, I rather think
it might be a good idea to allow macro calls at top-level of a module.
So one could say Import.all(some.pkg) to achieve import some.pkg.* and
so forth. And it might make sense to just have top-level macro calls,
that use Context.defineType, that act as a custom complement to class
and enum declarations.


2011/11/5 Heinz Hölzer <[hidden email]>:
> Do you mean something like "import MyMacro.importMyTypes()"?
>
> Am 05.11.2011 19:57, schrieb Juraj Kirchheim:
>>
>> +1. This would be very helpful. Also, it would be nice (although not
>> necessary) if one could add imports from a macro.
>>
>> 2011/11/5 Heinz Hölzer<[hidden email]>:
>>>
>>> Hi Nicolas,
>>>
>>> would it be possible to add a function like
>>> haxe.macro.Context.getLocalImports() or getLocalContextTypes() to the
>>> Context class? This method should return the Import Context in which an
>>> Expression is evaluated (maybe a list of types). Context.typeof already
>>> uses
>>> these types to determine the expression type.
>>>
>>> You can read more about my usage scenario in this thread:
>>>
>>>
>>> http://haxe.1354130.n2.nabble.com/New-haxe-stagging-nemerle-like-macro-available-on-github-td6954481.html
>>>
>>> especially in this post
>>>
>>>
>>> http://haxe.1354130.n2.nabble.com/template/NamlServlet.jtp?macro=print_post&node=6966421
>>>
>>> best,
>>> h
>>>
>>> --
>>> haXe - an open source web programming language
>>> http://haxe.org
>>>
>
>
> --
> haXe - an open source web programming language
> http://haxe.org
>

--
haXe - an open source web programming language
http://haxe.org


--
haXe - an open source web programming language
http://haxe.org