ddlog icon indicating copy to clipboard operation
ddlog copied to clipboard

include/import other files

Open netj opened this issue 9 years ago • 6 comments

To be more pragmatic for real users, sharing common schema declaration, etc. will be necessary.

One easy way to implement this is with the cpp C/C++ macro processor and let users use something like #include "shared.ddlog". We already ignore all the # lines as comments so this already works in some sense. Except the error messages will all refer to incorrect positions since the file name and line numbers are all ignored.

If we want to design a better module system, namespace, etc., this needs some more thought. Please comment. Any ideas are welcome.

UPDATE:

  • This will fix #57

netj avatar Aug 10 '15 08:08 netj

This will fix #57

netj avatar Jan 30 '16 01:01 netj

This seems like a great solution. The "shared.ddlog" is one use case -- an exploding star topology. Another use case is an imploding star -- a master app combining children apps.

Can we incorporate such cpp expansion into DD?

alldefector avatar Mar 25 '16 00:03 alldefector

Yes, we can add a step to DD compiler to run cpp right before ddlog compile and it'll just work, but the file/line numbers in the error messages will be out of sync. Fixing the parser to pick up those lines required a deeper understanding of Scala's parser combinators, so I was stuck there. However, nothing prevents the cpp step to be done before/outside deepdive compile, so it's already possible to organize the code with these #include directives.

netj avatar Mar 25 '16 00:03 netj

It'd be easier if DD does the expansion behind the scene... How about generating an expanded ddlog file so the line numbers make sense at least for this file?

Also, hopefully we don't have to introduce ifndef etc. to avoid issues like repeated inclusion... Maybe the compiler could do the ifndef wrapping automatically?

alldefector avatar Mar 25 '16 00:03 alldefector

If we support cpp output, I think we shouldn't try to improve anything. For smarter things, I prefer doing a proper module support in the language itself. @chrismre also thinks Julia/nodejs-style everything-nested-under-some-local-name module system would be ideal. Mapping such nested module namespaces to the database table names and the input/ and run/process/ filename conventions will be the things to figure out for this direction.

netj avatar Mar 25 '16 01:03 netj

OK, we'll just use external cpp for now.

alldefector avatar Mar 25 '16 01:03 alldefector