On Friday, April 21, 2017 09:31:52 Martin Tschierschke via Digitalmars-d- learn wrote: > Is it possible to define an alias for something like > > mixin(import("local_function_file.d")); > > to write only > > use_local_function; > > which will be translated to: > mixin(import("local_function_file.d")); > > (this additionally needs the file local_function_file.d in > source/ + > -J./source as parameter for dmd aka. dflags "-J./source" in > dub.sdl) > > Regards mt.
You can alias symbols. You can't alias statements, and mixins are always explicit. Now, you could have a function that returned what you wanted to mix in so that you just did something like mixin(use_local_function()); and have use_local_function return whatever code it is you want to mix in, but you can't just do something like use_local_function; and have it work. That would be more like a macro system, and D doesn't have that. We have string mixins and template mixins, but those are both explicitly mixed in. - Jonathan M Davis