Giter Site home page Giter Site logo

goodlang / good Goto Github PK

View Code? Open in Web Editor NEW
29.0 7.0 3.0 76.51 MB

The Good Programming Language

License: BSD 3-Clause "New" or "Revised" License

Shell 0.18% Go 88.56% Fortran 0.01% C 0.50% Assembly 5.84% HTML 4.76% JavaScript 0.01% Protocol Buffer 0.01% C++ 0.01% Batchfile 0.02% Makefile 0.01% Logos 0.01% Awk 0.01% Perl 0.09% CSS 0.01% Python 0.03%
programming-language golang good goodlang

good's People

Contributors

0intro avatar aclements avatar adg avatar agl avatar alexbrainman avatar ality avatar bradfitz avatar cherrymui avatar cixtor avatar crawshaw avatar davecheney avatar dr2chase avatar dsnet avatar dsymonds avatar dvyukov avatar griesemer avatar ianlancetaylor avatar josharian avatar ken avatar mdempsky avatar minux avatar mpvl avatar mundaym avatar mwhudson avatar niemeyer avatar nigeltao avatar randall77 avatar remyoudompheng avatar robpike avatar rsc avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

good's Issues

Thread-safe (lock-free) maps

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 throws about concurrent write/read-write, fix growWork and evacuate() and write as many as possible tests for maps.

  • basic implementation
  • tests

?. operator

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

ADT

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
}

Optional types

Please answer these questions before submitting your issue. Thanks!

What version of Go are you using (go version)?

go1.8beta1

What operating system and processor architecture are you using (go env)?

windows/amd64
linux/amd64

What did you expect to see?

Something like

type RequestResult option{
   error
   Response 
}

and

type LoggerOptions option{
    JSON
    Text
    Protobuf
}

What did you see instead?

Pain, darkness and "const-iota" hell

Add Goox Component System

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

Constructors & Destructors

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
}

Setup CI

We should setup a CI, e.g. travis CI etc.

Add `?` pseudo-variable

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()
}

Statement => Expression

func Foo(a int) int {
  return if a > 100 {
    0
  } else {
    -1
  }
}

b := switch c {
  case 0: -1
  case 1: 1
  default: 666
}

Multisignatures

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
}

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.