Fork me on GitHub
#sci
<
2021-01-03
>
Timur Latypoff07:01:37

Is there a simple way to know, on which vars a specific parsed form depends? Say, “if these vars existed, this form would run”.

borkdude09:01:09

@timur058 Can you give an example?

Timur Latypoff10:01:06

For example, if I wanted to make something like https://observablehq.com, but for Clojure by using sci. In Observable, you have live notebooks made of several snippets of code. These snippets may depend on each other (one of them declares x and another one uses it in calculation), but don’t have to be in some particular order. Observable internally resolves the dependencies of snippets and executed them internally in “correct” order. Also, if x changes, it re-runs all snippets that depend on it or depend on dependent snippets. I wonder if sci has an API that would say: “this form you provided depends on these vars being present in context (that are currently missing)”. This way, one could build a dependency tree of how snippets depend on each other, and execute them in “correct” order.

borkdude10:01:35

Usually this is done through namespaces and requires

Sam Ritchie12:01:51

@timur058 I’m not sure either but I see what you want and agree that it’s important. If you had this, you could pre-evaluate all of the cells in the notebook

Sam Ritchie12:01:58

in proper order when it’s loaded

Sam Ritchie12:01:11

(as you say in the comment, duh 🙂 )

Sam Ritchie12:01:18

looks like a problem we need to solve!

borkdude12:01:30

@U017QJZ9M7W Is this something sci should solve or is this some topological sort problem that should be solved in a sci-using app? And why not use namespaces for this? The namespace system already solves this problem

Sam Ritchie12:01:49

@U04V15CAJ my guess is that what @timur058 wants to enable is the ability to define “cells” of some notebook out of order, and as long as everything COULD be sorted, then great. I don’t think it’s an sci-level problem since this would have to happen before feeding the forms into sci

borkdude12:01:03

if you use namespaces like:

(ns cell5 (:require [cell1]))
this would work, and you could artificially prepend these namespace things in front of the expressions

❤️ 3
Sam Ritchie13:01:39

brilliant, I like it

borkdude09:01:29

Does this have to do with allow/deny settings?

Timur Latypoff10:01:06

For example, if I wanted to make something like https://observablehq.com, but for Clojure by using sci. In Observable, you have live notebooks made of several snippets of code. These snippets may depend on each other (one of them declares x and another one uses it in calculation), but don’t have to be in some particular order. Observable internally resolves the dependencies of snippets and executed them internally in “correct” order. Also, if x changes, it re-runs all snippets that depend on it or depend on dependent snippets. I wonder if sci has an API that would say: “this form you provided depends on these vars being present in context (that are currently missing)”. This way, one could build a dependency tree of how snippets depend on each other, and execute them in “correct” order.