Stencila will provide a standard library of useful function, just like MS Excel does. However, often you want to do something specific, and you’d know how to implement that in just a few lines of Javascript or Python…

Meet Stencila Functions

Let’s assume you are editing a spreadsheet and entering a cell expression (Mini). Now just type the function call as it were already defined. When the cursor is over the function name you’ll see a prompt that let’s you create a new function definition.

We show the function editor in a modal dialog, where you can choose the implementation language, adjust the signature and write the source code. On confirmation the dialog would close and you’d see the results of your expression ran through your custom function.

The same would work from within Documents, when you could call custom functions in your code cells.

We believe that sharing methods in research becomes more and more important. By giving algorithms a (function) name and documenting their usage they become reusable. We hope that in the future scientists could cite or even call a function x of publication y.

However that’s for the future. For now I’d just want to know from you how you would use such a feature. I’m also interested in evaluating whether creating a set of custom functions and gluing them together could be used as an alternative to the Notebook paradigm (e.g. Jupyter, RMarkdown) where source code is written inline and run in a global execution context. The beauty of the function abstraction would be that users can define functions in different languages and compose them in arbitrary ways. It’s also nice to provide the reader a high level view on your research methods, rather than just showing them the code straight away. Source code can get pretty complicated to read, while simple Excel-like expressions give you a good overview. For instance your document could look like this: