Comments (9)
I largely second others in thinking that putting std
functionality in os
is a tough fit. I think time.Now()
returning the block time is a good exception, because as long as we explain the differences, everything else in time still works the same (though, even then, a good consideration might be to rename Now()
to something more descriptive like BlockTime()
, but I digress).
I don't like std
as a name because I think it is too generic and would like for it to be broken down. os
is largely not a good fit and a misnomer (you are not accessing the OS, and calling Gno.land an "OS" is a stretch of imagination). But I think runtime
, in this regard, is a much better fit. Go's runtime
package already exposes many meta-runtime features that make sense within Go programs, so I think in this case we can have the runtime
package with a different API.
I propose the following (sorry, I detoured on a redesign of all of the function names, hope you'll forgive me):
- Package
runtime/chain
OR justchain
(or variantsblockchain
,bc
), containing:- types
Address
,AddressList
DerivePkgAddr
(better name:AddressFromPkgPath
?)EncodeBech32
/DecodeBech32
- type
Banker
- type
Coin
,Coins
- type
Realm
- type
RawAddress
(better: either remove, or make functions likeEncodeBech32/DecodeBech32
use it
- types
- Package
runtime
, containing:GetCallerAt
(better:CallerAt
)GetOrigCaller
(better:OriginCaller
)GetOrigPkgAddr
(better: axe this in favour ofOriginPkgPath
+chain.AddressFromPkgPath
)GetBanker
(better:NewBanker
) +BankerType
GetOrigSend
(better:OriginSend
)CurrentRealm
,PrevRealm
CurrentRealmPath
(better: axe in favour of CurrentRealm.Path)GetChainID
(better:ChainID
)GetHeight
(better:Height
,BlockHeight
)AssertOriginCall
/IsOriginCall
In other words, I like to have a package chain
which defines key blockchain-specific types (and utility functions for them), and have a runtime
package that accesses the "meta-gnovm" features.
In a kind of way, this is similar to package io
(define types, interfaces and useful helper functions) and package os
(access the filesystem, often through io
types).
from gno.
Let this comment be a poll:
Idea 1: as per @thehowl's comment, split std
into chain
& runtime
. Vote with 🚀
Idea 2: simply rename std
to gno
. Vote with 🎉
Idea 3: keep std
as is. Vote with ❤️
In addition, I think that no matter the case, we should decouple classic std
functions from functions used for test context editing (ie std.TestSetOrigCaller
), and do some name refactoring to make function names more clear from the get-go.
from gno.
Also, one more thought.
I'd reserve gno
to be used as a keyword, just-in-case. (And thus not use it as an identifier anywhere)
Maybe the way we implement goroutines is different enough that a better fit is to change the keyword entirely to gno
:)
from gno.
I'm with the opinion to avoid overwriting any existing Go stdlib package names to avoid confusing: those who often switch between the languages, the searchability within the codebase (as os
is used internally), as well as misc. auto-import tools.
I don't think renaming this library is necessary but I'm curious to hear what others think; or we can determine as a collective rather how to refer to the current std
package, as we have been discussing.
from gno.
I have experienced similar feelings on multiple occasions.
Here are my current ideas, listed randomly:
- Keep the name as
std
. - Change the name to
os
to align with Golang's package. However, this would result in significant API differences. For a blockchain-less version of gnovm, such as for CLI scripting, we could enable the actualos
. - Rename it to
gno
since it is specific to running on a gnovm blockchain. We can imagine a blockchain-less version of a gnovm-powered server with a completely differentstd
package. - Move it to a userland package like
gno.land/p/std
to only have shared std libraries with Go. This would be facilitated by merging the native binding PR (#859), but it might create more ambiguity.
from gno.
With 1. we will need workarounds in order to discuss/document the std package (not that big of a deal, but still), so essentially I am for modifying the name.
I believe 2. is a totally valid concern. I think "gno"
is quite intuitive and unique enough to not get confused with anything.
Are there any technical challenges in regarding to doing this kind of renaming?
from gno.
I can't see any significant technical challenges. It's primarily a challenge related to language design and concerns about adoption and documentation.
Remember that it will be the most widely used import. It's kind of similar with choosing the right keyword, like "return," "panic," "switch," or "for,". It should be something memorable, similar to the well-known if err != nil
, which is strongly associated with go.
from gno.
I like the name std
and not renaming it to os
or something else that overloads an existing go standard library package name. In my opinion, If we want to apply more meaningful names to groups of functionality within std
is the perfect name to avoid naming conflicts with go standard library packages because go does not allow packages to be named std
.std
, then I'd suggest grouping them into subpackages.
I think it is better to keep it out of the normal "userland" package space because of the native bindings that it is built on. I think it makes sense in general for ONLY standard library packages to be able to define native bindings. And in fact, now that the native bindings PR has been merged, it ensures that they are only supported in standard library packages.
So TLDR; I don't support renaming this package but am fine with reorganizing into subpackages.
EDIT: see the strikethrough above; I thought I encountered this the other day but I was wrong
from gno.
os/gno
or syscall/gno
?
Similar to syscall/js
from gno.
Related Issues (20)
- `sdk/vm` should perform precompiling and basic validation on `MsgAddPkg` HOT 2
- feat: make `AssertOriginCall` always panic with `MsgRun`
- feat: `PrevRealm` has the same behavior between `MsgRun` and `MsgCall` HOT 2
- Unable to call modifying methods on types imported from other realms HOT 1
- Interoperability
- Discussion: persist a pointer to an array element
- Make `banker.SendCoins` take variadic `Coin` argument HOT 3
- Best practices
- Annotate `does not implement` preprocessing error HOT 1
- Rename `baseOf` to avoid overloading the term
- realm maps not initialized with a filetest HOT 2
- security: is there a bug bounty policy? HOT 2
- Requesting GNOLAND added to Trustwallet
- Add high-level section pages to docs.gno.land
- Ensure that block timestamps proposed by validator is not anomalous HOT 1
- In filetests, PrevRealm().Address is std.GetOrigPkgAddr(), instead of std.TestSetOrigCaller's HOT 4
- Add network configurations table to docs
- Feature request: Unique time.Now() per transaction HOT 1
- Conflicting `chainID`s used for network RPC addresses HOT 1
- [RFC] Go-Gno testing framework
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from gno.