|
Re: macros attached to methods: msg#00004lang.nemerle.devel
One of possible uses was implementation of Aspects-Oriented Programming, though the required support by compiler would be quite large - we would need to easily attach given macro by its name to the set of chosen methods. Then, upon every call of method x.foo () we could wrap it with some generated code: beginTransaction(); try { x.foo(); } finally { endTransaction(); } The other point is that such macros would allow very convenient and localized macro expansions. You wouldn't need to define macro, which captures some name, but attach it to some standard method instead. The example from my MSC Thesis is the design pattern, which tells you to use factory method to construct objects, instead of direct calls to constructors. Assuming you have plently of calls to some constructor, attaching a single macro to it is much easier than converting all those calls. So, I guess the usage scenarios are maybe rare, but not completely absent ;) Maybe we should consider having this functionality in future (e.g. if we would do some refactoring to put methods + builting operators + extensions methods into one bag, this bag could possibly also contain extension macros). -- Kamil Skalski http://nazgul.omega.pl
|
|
| <Prev in Thread] | Current Thread | [Next in Thread> |
|---|---|---|
| Previous by Date: | List comprehensions ranges, mei |
|---|---|
| Next by Date: | Re: List comprehensions ranges, Kamil Skalski |
| Previous by Thread: | macros attached to methods, Michal Moskal |
| Next by Thread: | Re: macros attached to methods, Kamil Skalski |
| Indexes: | [Date] [Thread] [Top] [All Lists] |
| News | FAQ | advertise |