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

require/load as part of the syntax #20

Closed
markburns opened this issue Dec 14, 2014 · 7 comments
Closed

require/load as part of the syntax #20

markburns opened this issue Dec 14, 2014 · 7 comments

Comments

@markburns
Copy link
Contributor

This comment #18 (comment) made me think that it would be awesome to have some way of pulling in other streem files inline.
Maybe something like method_missing would look on the file system. Or an explicit syntax for pulling streems in so they could be preloaded.

#main.stm
STDIN | %x{split_into_lines} | map %x{match_today} | STDOUT

#split_into_lines.stm
STDIN.split("\n") | STDOUT

#match_today.stm
STDIN.match Date.today | STDOUT

or with method missing style

STDIN | split_into_lines | map match_today | STDOUT
@markburns
Copy link
Contributor Author

Actually having written those examples and forgotten STDIN STDOUT for some of them I also think they should be implicit

@jstoja
Copy link

jstoja commented Dec 14, 2014

+1 they should be implicit !

@matz
Copy link
Owner

matz commented Dec 14, 2014

I think you should be able to abstract part of stream in a form of a function, e.g.

def split_into_lines {
  current.split("\n")
}
def match_today {
  current.match(Date.today)
}
STDIN | split_into_lines | match_today | STDOUT

I am not sure if proposed process model fit well in the language.

@nickserv
Copy link
Contributor

@matz I agree, I like the idea of making STDIN and STDOUT at least somewhat explicit so that it's easier to abstract over streams. Something like STDIN | main | STDOUT could be used as the equivalent of a main function.

@markburns
Copy link
Contributor Author

@matz obviously this example is trivial and is more suited to your abstraction. For the file loading stuff I was thinking of more complex/larger pieces of code.

@nicolasmccurdy would there be a problem with having it implicit as well as optionally explicit?

@alexispurslane
Copy link

Personally, I like the %x{file-to-load} syntax best, because it is fairly concise, knows exactly which file to load, and isn't completely implicit. Although I do thing a more obvious, less strange syntax, such as {{file-to-load}} would be better. And functions would still be possible. This isn't a mutually exclusive thing.

@shuichiro-makigaki
Copy link
Contributor

I think we need 'stream processing function' definition as @matz says. In addition, the namespace concept should be defined such as class, package or namespace. import statement may be useful because it's intuitive.
Anyway, basically I also would like to add +1 to @markburns.

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

No branches or pull requests

6 participants