Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

decorators in separate files #6

Open
nteetor opened this issue Nov 21, 2016 · 1 comment
Open

decorators in separate files #6

nteetor opened this issue Nov 21, 2016 · 1 comment

Comments

@nteetor
Copy link
Owner

nteetor commented Nov 21, 2016

The initial release of tinsel (0.0.1), source_decoratees expects decorators to be defined in the same file as their decoratee. Allowing decorators to live in a separate file would be beneficial for the programmer and would allow flexible file organization.

In python one can import a decorator buzz like so,

import bazz

@bazz.buzz
class fizz:
    pass

If we consider using something of this fashion for tinsel the following operators are already used for a similar, but not indentical, task: ::, :::. Using :::: seems excessive: #. bazz::::buzz. Note that there would not be an import bazz equivalent. One could already work around this definition issue using source if they felt inclined to do so.

Is there an alternative symbol we could use?

nteetor pushed a commit that referenced this issue Nov 27, 2016
@nteetor
Copy link
Owner Author

nteetor commented Nov 28, 2016

Decorators found in separate files may be referred to with the following syntax,

#. separate-file$as_http_response

as in,

#. separate-file$as_http_response
fizz <- function(n) {
  paste0('fizz', strrep('z', n))
}

In this example separate-file is another .R file which contains a definition for the decorator as_http_response. The file extension is assumed to be ".R" and does not have to be included. Any other extension must be specified as part of the decorator line (in this case ".R" is not appended). See below,

#. my-way.r$as_response

In either case, the separate file is assumed to exist in the same directory as the decoratee's file. So for the example, the file containing fizz and the file containing as_http_response (or as_response) must exist in the same folder.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
version 0.0.2
In Progress
Development

No branches or pull requests

1 participant