[go-nuts] Re: Generics and parentheses

2020-07-14 Thread Ahmed (OneOfOne) W.
This feels a little better, but honestly I'm still all for angle brackets 
or like Watson suggested, guillamets.




*fn(T1)(fn2(T2)(fn3(T3)(v))) // 1fn[T1](fn2[T2](fn3[T3](v))) // 
2fn(fn2(fn3(v))) // 3fn«T1»(fn2«T2»(fn3«T3»v)))  // 4*

To me, with a background in C++ and Typescript and a little bit of Rust, #3 
and #4 are just natural and easier to read.

Regards,
Ahmed W.
On Tuesday, July 14, 2020 at 9:44:53 PM UTC-5 watso...@gmail.com wrote:

> Guillamets are worth consideration. They are common on European keyboards 
> and avoid all the syntax ambiguities.
>
> While a technical violation of compatibility by adding new reserved 
> characters, in practice I doubt this will be an issue given the semantics 
> of guillamets.
>
> Sincerely,
> Watson 
>

-- 
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to golang-nuts+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/golang-nuts/f060465f-9e61-43f6-b124-22c394dc67d5n%40googlegroups.com.


[go-nuts] [ANN] GemX: Generics For Go, Yet Again.

2017-08-25 Thread Ahmed (OneOfOne) W.
GenX  is a project I've been working on 
and I'd like some feedback (code documentation and tests are lacking atm, 
working on that).
I designed it to be as simple as possible while being able to handle 
advanced scenarios.

For example, if the input file/package only uses one type (aka 
`interface{}`) you don't have to change anything.

However you can target types, remove functions/types and all kinds of other 
things based on what you need.

Advanced example does different things based on the passed types:

   - https://github.com/OneOfOne/cmap/blob/master/cmap_if_string.go
   - https://github.com/OneOfOne/cmap/blob/master/cmap_if_other.go
   
Features
   
   - It can be *easily* used with go generate, from the command line or as 
   a library.
   - cmd/genx Uses local files, packages, and optionally uses go get (with 
   the -get flag) if the remote package doesn't exist.
   - You can rewrite, remove and change pretty much everything.
   - Allows you to merge a package of multiple files into a single one.
   - *Safely* remove functions and struct fields.
   - Automatically passes all code through x/tools/imports (aka goimports).
   - If you intend on generating files in the same package, you may add // 
   +build genx to your template(s).
   - Transparently handles genny 's 
   generic.Type.
   - Supports a few seeds 
   .
   - Adds build tags based on the types you pass, so you can target specifc 
   types (ex: // +build genx_t_string or // +build genx_vt_builtin )
   - Automatically handles nil returns, will return the zero value of the 
   type.
   - Doesn't need modifying the source package if there's only one type 
   involved.



-- 
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to golang-nuts+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[go-nuts] Using atomics for close checks

2016-10-04 Thread Ahmed (OneOfOne) W.
Some of our code uses something like:

type Dummy struct {
closed int64
}

func(d *Dummy) IsClosed() bool {
return atomic.LoadInt64(&d.closed) == 1
}

func(d *Dummy) Close() error {
if !atomic.CompareAndSwapInt64(&d.closed, 0, 1) {
return fmt.Errorf("already closed")
}
// other logic
return nil
}

IsClosed feels racy to me, is it better to use atomic.CompareAndSwap(&d.closed, 
1, 1) for IsClosed?


-- 
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to golang-nuts+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.