goodlang / good Goto Github PK
View Code? Open in Web Editor NEWThe Good Programming Language
License: BSD 3-Clause "New" or "Revised" License
The Good Programming Language
License: BSD 3-Clause "New" or "Revised" License
We want to get rid from using mutex when working with maps.
We need to fix concurrent read/write in maps.
To do that we need to remove throw
s about concurrent write/read-write, fix growWork
and evacuate()
and write as many as possible tests for maps.
As @onokonem proposed, we can add ?.
operator for structures, that basically struct field or nil
operator.
reason is:
if structA.FieldA != nil {
someVar = structA.FieldA.FieldB
}
vs
someVar = structA.FieldA?.FieldB
Using modern stack like react.js.
Needs generics.
type Maybe a = Just a | Nothing
type Either a b = Left a | Right b
type Tree a = Node a | (Tree a, Tree a)
Bonus: monads
interface Monad a {
func Bind<b>(Monad a, func(a) Monad b) Monad b
func Return(a) Monad a
}
func Bind<a>(ma Maybe a, f func(a) Maybe b) Maybe b {
r := match ma {
case Just a: f(a)
case Nothing: Nothing
}
return r
}
func Return<a>(x a) Maybe a {
return Just x
}
Please answer these questions before submitting your issue. Thanks!
go version
)?go1.8beta1
go env
)?windows/amd64
linux/amd64
Something like
type RequestResult option{
error
Response
}
and
type LoggerOptions option{
JSON
Text
Protobuf
}
Pain, darkness and "const-iota" hell
package someComponent
type Comp struct {
GooxComponent
}
func (c *Comp) Render() GooxComponent {
return (
<div class="some-component">
{c.Childs}
</div>
)
}
package template
import "someComponent"
func Render() GooxComponent {
var s = <span>span from var</span>
return (
<someComponent.Comp>
<div class="abc" style={ GooxStyle{ Padding: 10 } }>
<p>Goox demo</p>
{s}
</div>
</someComponent.Comp>
)
}
package main
import (
"template"
"fmt"
)
func main() {
fmt.Println(template.Render())
}
should print in console:
<div class="some-component">
<div class="abc" style="padding: 10px">
<p>Goox demo</p>
<span>span from var</span>
</div>
</div>
also should be printable as a struct with fmt.Printf("%#+v", gooxcomp)
and be compatible to work with struct syntax like gooxcomp.Style.Padding
If new(*T)
func defined in struct, it will be called via new(T)
func call.
If destruct(*T)
func defined in struct, it will be called when GC will delete the object.
To get this done, we should implement multisignatures and allow to define new and destruct funcs in struct{}
definition.
If destruct(*T)
defined anywhere else, it works like custom functions and should not be called via GC event.
User should be able to define destruct(*T)
in struct and destruct(*T)
anywhere else in package and it should work as defined above.
package main
type A struct {
B int
C *A
func new(a *A) {
a.B = 15
a.C = &A{
B: a.B << 2,
}
}
func destruct(a *A) {
a.C = nil
}
}
func (a *A) plus10() int {
a.B += 10
return a.B
}
type B struct {
A
B int
C *A
}
func main() {
abc := new(A) // calls *A.new() defined in struct{}
// but not *A.new() defined anywhere else
abc.C.plus10() // 70
}
We should setup a CI, e.g. travis CI etc.
Now we should write tons of boilerplate code like
x, y, z, err := someFunc(a, b, c, d)
if err != nil {
return err
}
or
x, y, z, err := someFunc(a, b, c, d)
if err != nil {
log.Printf("some error occurred: %s", err)
}
So we can support ?
pseudo-variable, just like _
but with next logic:
if user defines a func, that returns error, the next code will return zero values for any returning variable but last error:
func someFuncWithErrReturn() (string, []byte, error) {
x, y, z, ? := someFunc()
}
if user defines a func that returns named variables and an error, the next code will return named variables and error:
func someFuncWithErrAndNamedRets() (a string, b int, c []byte, error) {
a = "a string"
b = 0
c = []byte{'0', '1', '2'}
x, y, z, ? := someFunc()
}
if user defines a func that returns named variables and an error, the next code will return named variables and error, but returned values from someFunc()
will overwrite a
, b
and c
:
func someFuncWithErrAndNamedOWRets() (a string, b int, c []byte, error) {
a = "a string"
b = 0
c = []byte{'0', '1', '2'}
a, b, c, ? = someFunc()
}
if user defines a func that is not returns any error, the error will be printed and function will return zero values for given types:
func someFuncWithoutAnyErr() (string, int, []byte) {
a, b, c, ? := someFunc()
}
As @kirillDanshin proposed, we can draw a new logo with Bobr Dobr (beaver).
func Foo(a int) int {
return if a > 100 {
0
} else {
-1
}
}
b := switch c {
case 0: -1
case 1: 1
default: 666
}
Support a //govet:nocopy
flag
Using proposal docs from https://github.com/golang/proposal/blob/master/design/15292-generics.md
Let's say we have this struct:
type SomeStore struct {
b int
c string
d float64
}
User should be able to define functions like:
func Store(n int) *SomeStore {
return &SomeStore{b: n}
}
func Store(c string) *SomeStore {
return &SomeStore{c: c}
}
func Store(d float64) *SomeStore {
return &SomeStore{d: d}
}
And methods:
func (s *SomeStore) Set(n int) {
s.b = n
}
func (s *SomeStore) Set(c string) {
s.c = c
}
func (s *SomeStore) Set(d float64) {
s.d = d
}
And more on methods:
func (a *A) Set(anotherA *A) {
a.b = anotherA.b
a.c = anotherA.c
a.d = anotherA.d
}
func (a *A) Set(c string) {
a.Set(15<<2, c)
}
func (a *A) Set(c int, d string) {
a.b = c
a.c = d
}
Hi. Golang's idiotic feature is that it disallows Allman brace style. It should be fixed in a fork. :) whitespace shouldn't matter.
We should use efaceconv concept and optimize goodlang's eface work.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.