nim-lang / RFCs

A repository for your Nim proposals.
136 stars 26 forks source link

Less Redundant Import/Export #282

Closed beef331 closed 3 years ago

beef331 commented 3 years ago

Currently the method of importing and exporting a module without any exceptions requires rewritting the module name in a new export as follows.

import path/tomodule
export tomodule

My suggestion is to use the * marker we already know and love to reduce the redundancy

import path/tomodule* #Replicates above
import path/[tomodule, othermodule]* #Imports and exports all modules inside the `[]`

I've asked about it in the real time chat but terrible place to talk about it. I realize this solves very little and reduces a minimal amount of redundancy, just want to see other views on it.

Araq commented 3 years ago

Sorry, cannot see this being accepted. Then Nim's macro system would have to deal with yet another syntactic variation.

timotheecour commented 3 years ago

this is useful, but note this is solvable using pure macros, no need to patch compiler.

Then Nim's macro system would have to deal with yet another syntactic variation.

it wouldn't, if implemented as a macro (say in some std/imports module). See https://github.com/nim-lang/Nim/pull/10527 which addressed another related aspect of imports via macros.

beef331 commented 3 years ago

@timotheecour Yea i knew it was possible in macros, was just curious if there was any possibillity it could get slid into the language. It's not too bad to use the import compile flag in a config file. Thanks for the replies though.

timotheecour commented 3 years ago

If it can be done with a macro, you'd need a very compelling reason for language support, which I didn't see described here.