Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

@liam-fitzgerald
Copy link
Contributor

Namespacing proposal:

  • Never prefix a type with the name of the app. e.g. always action never chat-hook-action
  • All files in /lib and /sur should have ^? on the main core. ^? makes the payload opaque, which means you can't pull in imports indirectly. (e.g. you can't import lib/chat-hook to get at action:sur:chat-hook-lib)
  • Each app should have precisely one /sur and one /lib file
  • App-associated files in /sur should be imported as
/-  hook=chat-hook :: inside the context of chat
/-  chat-hook  :: outside the context of chat
  • Associated files in /sur should be imported as
/+  hook-lib=chat-hook
/+  chat-hook-lib=chat-hook
  • JSON conversion functions should be under +dejs or +enjs inside the associated /lib file.
  • Imports with * should be avoided as much as is reasonably possible, especially in /app files.

Implements the above proposal for the chat-* apps.

If everyone's happy with this, I'd like to extends this style to the rest of the codebase

Improved the namespacing by dropping the app prefix on types, e.g.
chat-hook-action -> action. Compensated for shadowing by importing the
/sur files behind a face. End result is that a chat-hook-action becomes
an action:hook. Splits chat-json into lib/chat-{hook,store,view}. Uses
^? on changes files in /lib and /sur to discourage deeply nested
importing.
@matildepark
Copy link
Contributor

(Informal GitHub etiquette: only tag reviewers if they're required; cc optional reviews. This isn't codified yet iirc, but it helps clarify when merging.)

Copy link
Contributor

@tacryt-socryp tacryt-socryp left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Righteous! These are good conventions and these changes have been well-executed.

++ json
|= jon=^json
(json-to-view-action jon)
(action:dejs jon)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can just put ++ json action:dejs

++ json
|= jon=^json
(json-to-hook-action jon)
(action:dejs jon)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can replace with ++ json action:dejs

++ json
|= jon=^json
(json-to-action jon)
(action:dejs jon)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same

Copy link
Collaborator

@Fang- Fang- left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One thing I neglected to mention in conversation, @liam-fitzgerald, is that maybe lib and sur files for the stores themselves shouldn't have the -store suffix. Idea here being that the things in them are data structures and associated helpers for the entire suite of apps, not just the store.
So you'd get, for example, envelope:chat and action:chat in /sur/chat.hoon.

Wondering what you think of this. It does rub up against "1 file per app" a little bit, in that the relation is less literal.

Left some more comments below, but changes look good otherwise! Happy to see this done. (:

:: chat-store: data store that holds linear sequences of chat messages
::
/+ *chat-json, *chat-eval, default-agent, verb, dbug
/- store=chat-store
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We discussed importing "native" types (and maybe libs) with *, and thought we agreed on that? Having :store suffixes, inside of the store, feels a little bit silly to me. (Same goes for the other apps.)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've been flipping back and forth on this. I like having :store suffixes because

  1. using the autoname syntax doesn't shadow the type.
  2. It preserves a semblance of referential transparency inside the chat context. It's not uncommon to have to make changes to both the -store and -hook and I think preserving the namebindings is useful to prevent unnecessary context switches
  3. Types aren't really that hard up for space in most common syntactical situations, so identifier length is not really an issue here.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"Each file can get one sur * or one lib *, after that things get too confusing" seems like a reasonable compromise. Otoh -lib suffixes appearing anywhere are a sign that something has gone obviously wrong, and imo a fairly strong argument for a "stacking" model of "a library will frequently subsume the structure by the same name, pull in only one of them" - I don't believe e.g. inbox-to-configs:store would be overly unclear compared to inbox-to-configs:store-lib.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Having libs and matching surs under the same namespace sounds pretty nice, yeah. Lacking support for simultaneous /- name=thing and /+ name=thing, doesn't seem too unreasonable to just expose the types with the lib, under the assumption you're gonna need them anyway.

@liam-fitzgerald
Copy link
Contributor Author

One thing I neglected to mention in conversation, @liam-fitzgerald, is that maybe lib and sur files for the stores themselves shouldn't have the -store suffix. Idea here being that the things in them are data structures and associated helpers for the entire suite of apps, not just the store.
So you'd get, for example, envelope:chat and action:chat in /sur/chat.hoon.

Wondering what you think of this. It does rub up against "1 file per app" a little bit, in that the relation is less literal.

I kinda dislike this, because it implies (at least to me) that action:chat and action:chat-hook are somehow dependent, or that action:chat-hook is a subtype of action:chat. This is true for the chat apps, but is not necessarily the case for all apps. Also wondering how this works in relation to an incomplete 'suite' of apps. e.g. permission-group-hook.

@ohAitch
Copy link
Contributor

ohAitch commented Apr 29, 2020

Personally I would push for the ^? being part of the ford /- * syntax, so you can still structure things as multiple cores but have to be explicit about things. It's not being able to get at things at all that's an issue, it's them being spilled into a uniform namespace: if you see action:chat-sur:chat-lib due to both being qualified imports, you can follow that something funky is going on.

++ grab
|%
++ noun chat-hook-update
++ noun update
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Something I don't love here is these are in fact being sent over the wire as %chat-hook-update, which might warrant some verbosity in at least the marks and !<s for consistency. (Alternately the mark system should perhaps have some manner of namespacing… even like, %chat-hook--update would make intermittent usage of the bare name less awkward)

Comment on lines 1 to 2
/- *chat-view, *rw-security
|%
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm, but with the ^? removed, this would still expose the *rw-security. Wondering if there's some middle ground here where we can selectively expose only the types (core) "native" to the lib...

Copy link
Contributor Author

@liam-fitzgerald liam-fitzgerald Apr 29, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

could we just cons the sur import and the library core together? and then ^? the result

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh yeah, that seems to work.

You're gonna have to =, chat-view instead of importing as *chat-view though, which is bad-style use of =,. I guess the ends justify the means here.

Copy link
Collaborator

@Fang- Fang- left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Alright, this seems good! (:

Comment on lines 15 to 16
%text
(frond %text s+text.letter)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
%text
(frond %text s+text.letter)
%text
(frond %text s+text.letter)

The backsteps on these are still a bit too aggressive.

@tacryt-socryp
Copy link
Contributor

tacryt-socryp commented May 1, 2020

Liam the indenting you “fixed” is wrong... it was right before

@liam-fitzgerald liam-fitzgerald force-pushed the lf/chat-type-namespacing branch from 1ec3caa to 1faf359 Compare May 1, 2020 04:12
@liam-fitzgerald
Copy link
Contributor Author

Pls approve @loganallenc @Fang-

@tacryt-socryp
Copy link
Contributor

Morge

@matildepark
Copy link
Contributor

You have a merge conflict here @liam-fitzgerald

++ letter
|= =^letter
^- json
=, enjs:format
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

unnecessary

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What do you mean?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

oh right the tiscom

++ config
|= =^config
^- json
=, enjs:format
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

unnecessary

@matildepark
Copy link
Contributor

This has a merge conflict again.

When should this even be merged? And what target? It seems like these can go out whenever; they're more for developer benefit than user fixing.

@Fang-
Copy link
Collaborator

Fang- commented May 11, 2020

When should this even be merged? And what target?

afaic this can be merged when conflict is resolved, onto a release/next-userspace or release/next-ota.

@matildepark
Copy link
Contributor

ping @liam-fitzgerald Mind fixing the conflicts and targeting release/next-userspace for this and the other namespacing PRs?

@liam-fitzgerald liam-fitzgerald changed the base branch from master to release/next-userspace May 19, 2020 23:16
@matildepark matildepark merged commit 91cf06b into release/next-userspace May 19, 2020
@matildepark matildepark deleted the lf/chat-type-namespacing branch May 19, 2020 23:54
@liam-fitzgerald
Copy link
Contributor Author

Don’t merge yet I have to port the virtualisation changes

@matildepark
Copy link
Contributor

RIP sorry

You can make another PR for release/next-userspace?

@ixv ixv mentioned this pull request May 24, 2020
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

Successfully merging this pull request may close these issues.

6 participants