Comments (3)
This is an excellent idea!
We should start writing helpers in gno.land/p/something
(not rules
, can be too many different things) and consider making a top-level package only after encountering limitations with this method.
BTW, I prefer the procedural over declarative.
My 2cts:
- declarative makes more ambiguous stack traces.
for listing a set of conditions and makes building a code parser easier
-> I disagree. It's straightforward to parse in both cases.- less indirections.
If you're concerned about readability, we can use idiomatic go like this:
func Foo() {
{
rules.AssertPayable()
rules.AssertReadOnly()
rules.AssertPayableWith("...")
// ...
}
// ...
}
But I think keeping them at the top of functions with an empty line just after will be more than enough.
The good news is that we can manage to support both at the same time, but I'll prefer the procedural method for the official packages' implementation.
from gno.
Sounds good to have a package in p
for this. I was wondering if it would possible to implement ReadOnly
through this method since it would be something quite useful.
For procedural vs declarative, I guess it's personal preference, using brackets is actually already visual.
from gno.
I think a more go-ish approach would be to use comments to give more context to the clients, generate documentation, and so on.
It's the current way Go extends a source code for things that are for tools and humans.
Having a library for rules still makes sense for real assertions, i.e., I would not prevent people from making TXs for read-only stuff, a TX is more decentralized and uses the consensus + it will be IBC friendly.
So, for the example of read-only, I would add comments to suggest people call it using RPC instead of TX but not prevent it.
Also, mixing actual code and magic is more obscure than having explicit code for code and explicit comments for everything else non-code.
I suggest that anyone starts a rules package that will make sense. And consider parsing comments instead of code for everything related to annotations/suggestions.
from gno.
Related Issues (20)
- [Testnets] Make `staging.gno.land` consistent
- [GnoVM] Suggest `gno mod tidy` for unknown import
- [Memeland] App broken because max CPU cycles reached HOT 3
- Some packages are not recognized on the playground even if they exist HOT 1
- [Gnoweb] Display line numbers on package & realm source code renders
- Test4's initial DAO requirements (gov, worx, evaluation, etc)
- docs: tm2-js-client & gno-js-client are incomplete
- [chain] Standardize node directory structure
- [chain] Add a `genesis.json` path flag to `gnoland start`
- [chain] Drops file paths from `config.toml`
- [chain] Add the `gnoland init` command HOT 2
- [chain] Remove lazy chain initialization for `gnoland start`
- Ways to parse coins that sent directly to current realm HOT 1
- [docs] Docusaurus deployment preview
- Factory Pattern Gno HOT 4
- Backward compatibility
- workshops: forum tutorial tests failing HOT 1
- Error : cannot modify external-realm or non-realm object HOT 3
- [ux] Better DevX with root Makefile HOT 1
- feat: support `:=` type inference assignments in REPL
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.