# Interactions of d/basis-t, d/as-of, d/with

**URL:** <https://forum.datomic.com/t/interactions-of-d-basis-t-d-as-of-d-with/219>\
**Category:** General\
**Created:** [November 29, 2017, 4:21pm UTC](https://forum.datomic.com/t/interactions-of-d-basis-t-d-as-of-d-with/219 "2017-11-29T16:21:37Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![dustingetz](https://sea2.discourse-cdn.com/flex016/user_avatar/forum.datomic.com/dustingetz/32/56_2.png) [@dustingetz](https://forum.datomic.com/u/dustingetz)\
**Post date:** [November 29, 2017, 4:21pm UTC](https://forum.datomic.com/t/interactions-of-d-basis-t-d-as-of-d-with/219/1 "2017-11-29T16:21:37Z")

</div>

I was expecting for dbvals to have the same value semantics as Clojure data structures. This would mean I can have multiple timelines. In git parlance, “rewind and branch from past”. I understand that if the branch was pushed it would be a merge.

This does not work as I expected. My present understanding is: d/with will return a dbval with the most up-to-date d/basis-t which has been constrained by setting a d/as-of flag. So all dbvals will always have a basis-t of the highest t value known to the peer.

What is going on? Why is it implemented this way?

[Here is a gist demonstrating the weird semantics](https://gist.github.com/dustingetz/39f28f148942728c13edef1c7d8baebf)

Thanks

---

<div class="post-metadata">

**Author:** ![dustingetz](https://sea2.discourse-cdn.com/flex016/user_avatar/forum.datomic.com/dustingetz/32/56_2.png) [@dustingetz](https://forum.datomic.com/u/dustingetz)\
**Post date:** [November 30, 2017, 11:38pm UTC](https://forum.datomic.com/t/interactions-of-d-basis-t-d-as-of-d-with/219/2 "2017-11-30T23:38:43Z")

</div>

I now understand that as-of is implemented as a filter, and the semantics of using d/with on a filtered dbval is not clear or perhaps meaningless. Though things are still a little murky to me as to the exact semantics and if branching from the past is a reasonable thing to want to do (given that it can never be transacted) and why it is the way it is and not like Clojure’s data structures.

---

<div class="post-metadata">

**Author:** ![ttallman](https://sea2.discourse-cdn.com/flex016/user_avatar/forum.datomic.com/ttallman/32/528_2.png) [@ttallman](https://forum.datomic.com/u/ttallman)\
**Post date:** [January 23, 2024, 6:09pm UTC](https://forum.datomic.com/t/interactions-of-d-basis-t-d-as-of-d-with/219/3 "2024-01-23T18:09:42Z")

</div>

It would be great if db/with on an as-of db threw an error. I just had a developer loose 2 days because of this issue. I doubt anyone has the intuition these semantics.

---

<div class="post-metadata">

**Author:** ![nikolayandr](https://sea2.discourse-cdn.com/flex016/user_avatar/forum.datomic.com/nikolayandr/32/375_2.png) [@nikolayandr](https://forum.datomic.com/u/nikolayandr)\
**Post date:** [January 24, 2024, 1:04pm UTC](https://forum.datomic.com/t/interactions-of-d-basis-t-d-as-of-d-with/219/4 "2024-01-24T13:04:11Z")

</div>

Agree, I had the same issue

---

<div class="post-metadata">

**Author:** ![ttallman](https://sea2.discourse-cdn.com/flex016/user_avatar/forum.datomic.com/ttallman/32/528_2.png) [@ttallman](https://forum.datomic.com/u/ttallman)\
**Post date:** [March 6, 2024, 3:21pm UTC](https://forum.datomic.com/t/interactions-of-d-basis-t-d-as-of-d-with/219/5 "2024-03-06T15:21:23Z")

</div>

[https://docs.datomic.com/pro/time/filters.html#as-of-not-branch](https://docs.datomic.com/pro/time/filters.html#as-of-not-branch) is very clear. Either I missed it or it was not there the first time I read the docs. it may help to put this bit in the as of api docs.

---

<div class="post-metadata">

**Author:** ![onetom](https://sea2.discourse-cdn.com/flex016/user_avatar/forum.datomic.com/onetom/32/430_2.png) [@onetom](https://forum.datomic.com/u/onetom)\
**Post date:** [March 11, 2024, 7:36am UTC](https://forum.datomic.com/t/interactions-of-d-basis-t-d-as-of-d-with/219/6 "2024-03-11T07:36:03Z")

</div>

Datomic Cloud doesn’t have `d/filter`, so its docs lack the equivalent section, but since it does have `d/with`, I would still expect a mention of how we “can’t branch the past”.
