Re: [go-nuts] zombie parent scenario with golang

2020-09-11 Thread Bakul Shah
1. Looks like*something* in ps reports process/thread state incorrectly. It should not report until all the pthreads have exited and the parent has not picked up the status. The runtime will call exit() when the last thread terminates (exit() in turn will call the _exit syscall). 2. If any

Re: [go-nuts] List inside struct

2020-08-29 Thread Bakul Shah
Unless there is a very strong reason to use a doubly linked list, you should just use a slice: type Persons struct { name string; Names []string } I redid your program using the above here: https://play.golang.org/p/x5I1wYiCNGA Sounds like you are coming from some object oriented language

Re: [go-nuts] [ generics] Moving forward with the generics design draft

2020-08-21 Thread Bakul Shah
On Aug 21, 2020, at 2:07 PM, roger peppe wrote: > > Here's one interesting implication of this: it allows us to do type > conversions that were not previously possible. > > For example, if we have "type I int", we can use a type switch to convert > some type []I to type []int: >

Re: [go-nuts] [ generics] Moving forward with the generics design draft

2020-08-21 Thread Bakul Shah
On Aug 20, 2020, at 5:27 PM, Ian Lance Taylor wrote: > > After many discussions and reading many comments, we plan to move > forward with some changes and clarifications to the generics design > draft. > > 1. > > We’re going to settle on square brackets for the generics syntax. > We’re going

Re: [go-nuts] How to find repeated string?

2020-08-19 Thread Bakul Shah
On Aug 19, 2020, at 1:07 AM, 洪嘉鴻 wrote: > > Hello everyone: > I use golang with Win10. The version of golang which I'm using is go1.15. > I want to find out the repeated string. > For example, given a string which is "1134534534534534". > I want the output string to be "345" > I've tried to >

Re: [go-nuts] [ generics ] Added constraint type inference to the design draft

2020-08-13 Thread Bakul Shah
On Aug 13, 2020, at 3:29 PM, Michael Jones wrote: > > The all-or-none aspect would be sidestepped if it were allowed to define > "partial generics": > > func A (T1, T2) (...){} > > func B(T)(...){ A(T,int)(...){...} } > > Allowing B to exist just means running the whole generic thing

Re: [go-nuts] [generics] Feedback on optional type keyword experiment

2020-07-25 Thread Bakul Shah
I like it! BTW, I don't understand the meaning of this comment in the commit log: > >> Experiment: Make "type" keyword optional in generic type declarations when > >> it is clear that we can't have an array type declaration. It is talking about defining generic arrays, where one parameter may

Re: [go-nuts] Generics and parentheses

2020-07-15 Thread Bakul Shah
> On Jul 15, 2020, at 1:49 PM, Ian Lance Taylor wrote: > > On Tue, Jul 14, 2020 at 11:06 PM Bakul Shah wrote: >> >> I don't much like square brackets or angle brackets or guillemets. But here >> is a different way >> of reducing the need for parenth

Re: [go-nuts] Generics and parentheses

2020-07-15 Thread Bakul Shah
As I wrote, parentheses are not needed for the common case of single type parameter. If you have more than one, you need parentheses but note that this is a *prefix* and any parsing ambiguities can removed by using a - if needed. For your example it will be something like (float64,int)PowN(1.2,

Re: [go-nuts] Generics and parentheses

2020-07-15 Thread Bakul Shah
I don't much like square brackets or angle brackets or guillemets. But here is a different way of reducing the need for parentheses at least for the common case: A proposal for fewer irritating parentheses! One thing to note is that generic functions & types are *different* from existing things

Re: [go-nuts] var fn myHandler = func(){ fn }

2020-07-12 Thread Bakul Shah
On Jul 12, 2020, at 1:43 PM, Axel Wagner wrote: > > > > On Sun, Jul 12, 2020 at 9:33 PM Bakul Shah wrote: > On Jul 12, 2020, at 11:11 AM, Gert wrote: > > > > https://play.golang.org/p/6xMgjr1IyFD > > > > var fn myHandler > > fn = func(w http.Re

Re: [go-nuts] var fn myHandler = func(){ fn }

2020-07-12 Thread Bakul Shah
On Jul 12, 2020, at 11:11 AM, Gert wrote: > > https://play.golang.org/p/6xMgjr1IyFD > > var fn myHandler > fn = func(w http.ResponseWriter, r *http.Request) { > fn.GET(w, r) > } > > Just wondering if it's possible somehow to write this in one line like so > > var fn myHandler = func(w

Re: [go-nuts] filepath.Abs ignores '~'

2020-07-07 Thread Bakul Shah
You can do this: home, _ := os.UserHomeDir() absPath := home + "/trunk/infra/metadata/config.cfg" > On Jul 7, 2020, at 4:32 PM, 'Jacob Kopczynski' via golang-nuts > wrote: > > I tried to state a path relative to the home directory, since in the context > I am writing for the

Re: [go-nuts] draft design for // +build replacement

2020-07-01 Thread Bakul Shah
pothetical _fuzz even if otherwise things converge on go:build. > > On Wed, Jul 1, 2020 at 11:20 AM Bakul Shah wrote: >> >> 4. Use two underscores for constraints. At least new constraints. >> >> Aside: Are you plantin' an idea about Plan10? >> >> O

Re: [go-nuts] draft design for // +build replacement

2020-07-01 Thread Bakul Shah
4. Use two underscores for constraints. At least new constraints. Aside: Are you plantin' an idea about Plan10? > On Jul 1, 2020, at 11:06 AM, Russ Cox wrote: > > For what it's worth, I am (unsurprisingly) a big fan of the filename-based > constraints. It's a lightweight convention that has

Re: [go-nuts] Bitstring package?

2020-06-29 Thread Bakul Shah
Won't https://golang.org/pkg/math/bits/ do? > On Jun 29, 2020, at 6:58 PM, hardconnect@gmail.com wrote: > > I'm looking for a package that implements arbitrary length bit strings and > supports set all, clear all, set and reading back of arbitrary bits

Re: [go-nuts] Weird benchmark results for seemingly identical functions

2020-06-22 Thread Bakul Shah
They are not equivalent. You want if !(pos < suffixLen && pos < previousSuffixLen) {  break } in the second case.On Jun 22, 2020, at 5:15 AM, Yonatan Ben-Nes wrote:Hi,I'm encountering a weird issue which I fail to explain. It boils down to 2 almost identical functions which

Re: [go-nuts] How I can translate this shell command to golang code?

2020-06-22 Thread Bakul Shah
You can avoid calling the shell by observing that you are simply passing "123456" as input, which you can do in a Go Program itself. See https://golang.org/pkg/os/exec/#example_Command > On Jun 22, 2020, at 8:54 AM, Franco Marchesini > wrote: > > Help, > > how I can translate this shell

Re: [go-nuts] [generics] Type lists should be usable in any interface

2020-06-16 Thread Bakul Shah
On Jun 16, 2020, at 7:06 PM, Brandon Dyck wrote: > > I find it a little strange that an interface with a type list can only be > used as a constraint, and not as the type of a variable or parameter, despite > it using basically the same syntax as a normal interface. Is this difference >

Re: [go-nuts] Language proposal: labelled "with" statements to help make test code easier to write

2020-03-05 Thread Bakul Shah
On Mar 5, 2020, at 12:05 AM, roger peppe wrote: > > Having said all that, I believe there is a valid point to be made > with regard to testing concurrent Go programs that have long-lived > behaviour over time. It can be hard to test such programs, and I've > not yet seen an approach that doesn't

Re: [go-nuts] Language proposal: labelled "with" statements to help make test code easier to write

2020-03-03 Thread Bakul Shah
On Mar 1, 2020, at 12:43 PM, Ian Lance Taylor wrote: > > On Sun, Mar 1, 2020 at 8:21 AM Warren Stephens > wrote: >> >> // I don't want to get into the specific syntax of the test code directly, >> // but a test would start execution here, supplying "lines" and "thing2" >> // >>mystep2

Re: [go-nuts] Why Discord is switching from Go to Rust

2020-02-07 Thread Bakul Shah
> On Feb 7, 2020, at 10:44 PM, Eric S. Raymond wrote: > > On the other hand, for me to have tried to port reposurgeon to Rust > would have been a mind-numbingly stupid idea. And that will be true of > any application above a certain complexity of internal data-structure > management, where

Re: [go-nuts] net.conn TCP connection

2019-12-30 Thread Bakul Shah
> I am trying to understand what triggers the Csrc.Read(buf) to return The Read call will eventually turn into a read() system call. For TCP it will return as long as there is at least one byte in the kernel's receive buffer for this connection, or if the buffer give to read() is filled up, or

Re: [go-nuts] Разбить массив чисел на два массива

2019-12-01 Thread Bakul Shah
On Dec 1, 2019, at 1:06 PM, Harald Weidner wrote: > > Hello, > >> I'm not sure if that is a good idea  >> https://play.golang.org/p/Mj77pgsaVsB > > This is why three-index slices were added in Go 1.2. > > https://play.golang.org/p/_sJ9OKWsvMz > > https://golang.org/doc/go1.2#three_index

Re: [go-nuts] C variadic macro equivalent in Golang?

2019-11-30 Thread Bakul Shah
func PR(f string, a ...interface{}) { if d { return } fmt.Fprintf(os.Stderr, f, a...) } Add appropriate imports. > On Nov 30, 2019, at 12:08 PM, minfo...@arcor.de wrote: > > C allows comma-separated argument lists via variadic macros. Whereas AFAIK > golang allows only

Re: [go-nuts] Preprocessing "go" statements with preserved semantics

2019-11-08 Thread Bakul Shah
There is Massimiliano Ghilardi’s gomacro Github.com/cosmos72/gomacro Note that in case of untyped constants, there is no need to use temps so your idea can still work. >> On Nov 8, 2019, at 9:30 AM, Michael Jones wrote: >  > Alas. Thus the need for and glory of macros, hold/uneval, and

Re: [go-nuts] P-local/M-local storage for goroutines?

2019-07-23 Thread Bakul Shah
Instead of starting new goroutines, send requests to existing goroutines via a channel. In effect you are simulating an N core processor with per code local caches and one shared cache so you can look at how processors manage cache. Just create N goroutines at the start and profile to see what

[go-nuts] Re: [golang/go] Proposal: A built-in Go error check function, "try" (#32437)

2019-07-16 Thread Bakul Shah
And a big thank you to the Proposal Review Committee for shepherding this proposal & the ensuing discussion. "Open source community-wide discussion at its best" would be very hard to conduct without such a moderating influence. I learned quite a bit. Much appreciated. Cheers, Bakul > On Jul

Re: [go-nuts] The "leave "if err != nil" alone?" anti-proposal

2019-07-12 Thread Bakul Shah
I didn't quite get that. Sum-types is an independent issue (and can be made to work with try!). They seem to be using a slightly different definition of an error. They are saying an error is when a function fails even when all its preconditions are met. If the preconditions are not met, and

Re: [go-nuts] Announcing gg ("gigi") your new friend

2019-07-04 Thread Bakul Shah
Very nice! A natural great extension[1] would be language aware grep/sed/awk: - return an enclosing parse construct after matching something - match on a construct with some pieces wildcarded - replace one structure with another (but based on the match) Possible uses: - when you change an API of

Re: [go-nuts] `on err` alternative to `try()` has traction...?

2019-07-03 Thread Bakul Shah
May be indent(1) can be taught about Go syntax rules so that it can "pretty-print" ala Lisp? > On Jul 3, 2019, at 3:25 PM, Michael Jones wrote: > > Any form of restraining gofmt has my vote. One that I despise is ruining: > > switch v { > case ‘a’: doA = true > case ‘b’: doB = true > : > case

Re: [go-nuts] OOM occurring with a small heap

2019-07-02 Thread Bakul Shah
with the help of several people, a few of which have > peer reviewed the code. I agree it's most likely to be some runaway code that > I caused in my logic, but we haven't been able to pin-point the cause and > I've run out of hypothesis to test at the moment. This is why I've started &g

Re: [go-nuts] OOM occurring with a small heap

2019-07-02 Thread Bakul Shah
Before assuming it is the GC or something system related, you may wish to verify it is *not your own logic*. Larger RSS could also be due to your own logic touching more and more memory due to some runaway effect. The probability this has to do with GC is very low given the very widespread use

Re: [go-nuts] Go Language Survey

2019-06-12 Thread Bakul Shah
On Jun 12, 2019, at 8:24 AM, Michael Jones wrote: > > Bakul, these are good points. > > On the second, I used to always write (C/C++): > > If (things are good) { > happy case > } else { > sad case > } > > so the nesting was that the all-good was the first code block even when >

Re: [go-nuts] Go Language Survey

2019-06-12 Thread Bakul Shah
On Jun 12, 2019, at 7:36 AM, Michael Jones wrote: > > 128640 If statements, and just 8034 else, a 16:1 ratio. I'd like to > understand this better, There are two patterns that encourage this: x := v1 if someCond { x = v2 } And if someCond { return ... } The second pattern acts

Re: [go-nuts] Allow methods on primitives

2019-06-09 Thread Bakul Shah
On Jun 9, 2019, at 7:42 AM, Michael Ellis wrote: > > On Sunday, June 9, 2019 at 9:56:43 AM UTC-4, Bakul Shah wrote: > > You are almost always going to call a string's Render function > (as you defined it in your original post) from a parent HTMLTree > struct' Rend

Re: [go-nuts] Allow methods on primitives

2019-06-09 Thread Bakul Shah
On Jun 9, 2019, at 6:14 AM, Michael Ellis wrote: > > I'm not disputing the wisdom of Go's design. As I said at the top of the > initial post, I like Go the way it is and see no need for a Go 2. > > I was trying to find a clean solution to a specific use case: nestable > functions that

Re: [go-nuts] Remind me, please, about "taking over" a socket

2019-05-30 Thread Bakul Shah
On Thu, 30 May 2019 20:10:30 -0700 Bakul Shah wrote: > > You will have to use low level code like Socket(), Bind() etc. You can't > use e.g. Dial("tcp", "192.168.1.1:smtp") This should've been edited out since we are talking about Listen. -- You received this messa

Re: [go-nuts] Remind me, please, about "taking over" a socket

2019-05-30 Thread Bakul Shah
On Thu, 30 May 2019 17:40:55 -0700 David Collier-Brown wrote: > > My leaky brain has lost an old technique... > > Once upon a time, I would send an old copy of a program a SIGHUP, and it > would shut down a socket listening on, for example, port 25 (SMTP). A newer > release of the program

Re: [go-nuts] Performance comparison of Go, C++, and Java for biological sequencing tool

2019-03-06 Thread Bakul Shah
Thanks for an interesting read! Curious to know if you guys have any estimates on the number of lines, development time and number of bugs for each language implementation? I realize this is subjective but this comparison may be quite meaningful given that the authors had an existing reference

Re: [go-nuts] Is Go a single pass compiler?

2019-03-02 Thread Bakul Shah
Algol 68 allowed use before definition which would force more than one pass but I believe many Algol 68 compilers didn’t allow this and forced forward declarations much like in C. I suspect “multiple pass” makes less sense for modern compilers. When you can keep an entire program in memory, using

Re: [go-nuts] Go vs C speed - What am I doing wrong?

2019-02-12 Thread Bakul Shah
According to the C standard: If the quotient a/b is representable, the expression (a/b)*b + a%b shall equal a. In your example, dividing x by -1 would make x +2147483648, which is not representable in int32_t. May be this is why -2147483648/-1 also exceptions out?

Re: [go-nuts] Modules. A "new" system.

2019-02-05 Thread Bakul Shah
I hope bignums will be added to Go2 as a builtin type! -- 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

Re: [go-nuts] Go vs C speed - What am I doing wrong?

2019-02-03 Thread Bakul Shah
Suggestion: specify all relevant details as we don’t know what kind of machine you have. I suspect your machine is a 64bit word size machine. C ints are typically 4 bytes even on 64bit word size machines. Go ints are 8 bytes on these machines. Suggestion2: look at the generated assembly

Re: [go-nuts] Existing code for order-preserving concurrent work queue?

2019-01-31 Thread Bakul Shah
Here's a slightly different way of looking at this: It is known that if you have N servers, a single queue is better than N separate queues, so as to avoid the situation where you have an idle server with an empty queue and a waiting customer in a queue for a busy server. So the only other task

Re: [go-nuts] Memory usages

2019-01-30 Thread Bakul Shah
I think computing memory use of any *constant* is not straightforward and probably not worth it. Even a typed constant may only exist in an instruction stream. For instance "var x int64 = 42" may compile down to a single instruction (or more, depending on the underlying architecture). Or there

Re: [go-nuts] What does a deadlock mean in golang?

2019-01-30 Thread Bakul Shah
On Wed, 30 Jan 2019 12:21:46 -0800 Tom Mitchell wrote: > > On Tue, Jan 29, 2019 at 12:55 AM =E4=BC=8A=E8=97=A4=E5=92=8C=E4=B9=9F a.ito.dr...@gmail.com> wrote: > > > I know the general meaning of a deadlock, but I don't know the meaning of > > a deadlock in golang. > > > > Good question... > A

Re: [go-nuts] The performance comparation of Golang and Java

2019-01-25 Thread Bakul Shah
> On Jan 24, 2019, at 8:48 PM, Ian Lance Taylor wrote: > > On Thu, Jan 24, 2019 at 7:01 PM Karthik Krishnaswamy > wrote: >> >> I am just curious to understand what is the best possible way to increase >> the execution speed of this particular program ? I am still learning go >> though :)

Re: [go-nuts] This Makes No Sense

2019-01-22 Thread Bakul Shah
This is kind of like tic-tac-toe! The first player has an advantage. Gomoku's swap2 rule makes it fairer and more interesting! Also a good game to practice writing alpha-beta pruning search (for playing with a computer)! Representing the board as two sets of n^2 bitmaps would speed things up

Re: [go-nuts] Re: Suggestions for layout/structure/coding-patterns for GUI applications in Go?

2019-01-12 Thread Bakul Shah
On Sat, 12 Jan 2019 15:55:01 -0800 David Collier-Brown wrote: > > I'm pleasantly mature (born in 1644), but I still don't understand > javascript GUIs (;-)) Amazing. -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe from this

Re: [go-nuts] C++ 11 to Golang convertor

2019-01-07 Thread Bakul Shah
On Sun, 06 Jan 2019 17:01:20 -0500 "Eric S. Raymond" wrote: > > A simple, possibly correct LR parser for C11 > > http://gallium.inria.fr/~fpottier/publis/jourdan-fpottier-2016.pdf This paper says its lexer+parser is about 1000 lines, which doesn't include the preprocessor. For comparison, subc

Re: [go-nuts] What are the reasonable reasons to use pointers?

2019-01-02 Thread Bakul Shah
On Tue, 01 Jan 2019 22:56:06 -0800 Ian Lance Taylor wrote: > On Tue, Jan 1, 2019 at 6:42 PM Bakul Shah wrote: > > > > On Tue, 01 Jan 2019 03:34:34 -0800 =?UTF-8?B?5LyK6Jek5ZKM5Lmf?= > > wrote: > > > > > > What are the reasonable reasons to use pointers? A

Re: [go-nuts] Re: go for robotic control, walking balance, quad flight control

2019-01-01 Thread Bakul Shah
On Tue, 01 Jan 2019 15:40:41 -0800 Pat Farrell wrote: > > On Monday, December 31, 2018 at 4:19:50 PM UTC-5, minf...@arcor.de wrote: > > > > So perhaps you should saddle your horse backwards, and then decide if > > Golang as front-end development language > > is really the right choice for you.

Re: [go-nuts] What are the reasonable reasons to use pointers?

2019-01-01 Thread Bakul Shah
On Tue, 01 Jan 2019 03:34:34 -0800 =?UTF-8?B?5LyK6Jek5ZKM5Lmf?= wrote: > > What are the reasonable reasons to use pointers? Are pointers neseccary? Pointers are not necessary as a programming language feature but are necessary in implementing a programming language. As an example, Scheme

Re: [go-nuts] if/switch statements as expressions

2018-12-20 Thread Bakul Shah
On Thu, 20 Dec 2018 13:13:04 -0800 Michael Jones wrote: > > There is an inelegant but highly effective "hack" in GCC/G++ in thuas area. > Since C/C++ are expression language as Rob put it (e.g. a statement like > "3" compiles where in Go it fails with "3 evaluated but not used") GCC took > this

Re: [go-nuts] Pure functions and Go2

2018-12-14 Thread Bakul Shah
ng so is language complexity that a user has to face. Personally I'd rather see Go become a better higher level language. > > Not sure what you mean about complexity. The compiler would not be obligated. > > > On Fri, Dec 14, 2018 at 1:12 PM Bakul Shah wrote: > On D

Re: [go-nuts] Pure functions and Go2

2018-12-14 Thread Bakul Shah
On Dec 14, 2018, at 12:50 PM, Michael Jones wrote: > > Have been thinking about pure functions (in the Scheme sense of no > externalities other than constants and pure functions and no side effects) in > the context of weak metaprogramming and compiler optimization. Here is the > idea.

Re: [go-nuts] Package Stutter

2018-12-03 Thread Bakul Shah
package. Now you > need to override the import on one of them. No difference IMO. > >> On Dec 3, 2018, at 10:03 AM, Bakul Shah wrote: >> >>> On Dec 3, 2018, at 6:52 AM, Robert Engels wrote: >>> >>> I think people are misunderstanding my equal footing n

Re: [go-nuts] Package Stutter

2018-12-03 Thread Bakul Shah
On Dec 3, 2018, at 6:52 AM, Robert Engels wrote: > > I think people are misunderstanding my equal footing need. I don’t mean for > all applications, I mean for a application. > > Here’s another example. You have a enterprise payroll application. You have a > model package. You have

Re: [go-nuts] Package Stutter

2018-12-03 Thread Bakul Shah
On Dec 2, 2018, at 11:39 PM, robert engels wrote: > > what I’m really trying to convey is that “Fixed” is a top-level type, on > equal footing with ‘string’. a) it is *not* on equal footing with the built in types of Go. b) it can't be, as "Fixed" by itself not well defined. The Fixed type

Re: [go-nuts] Package Stutter

2018-12-01 Thread Bakul Shah
ints) before you can claim that any design > “needs change”. > > On Dec 1, 2018, at 12:18 PM, Bakul Shah wrote: > >> Reducing stutter.Stutter is a good thing. But coming up with meaningful >> names ThatDontTakeHalfALineAndReduceCodeDensity is often quite >> hard (

Re: [go-nuts] Package Stutter

2018-12-01 Thread Bakul Shah
Reducing stutter.Stutter is a good thing. But coming up with meaningful names ThatDontTakeHalfALineAndReduceCodeDensity is often quite hard (but ultimately rewarding as it forces you to think more clearly). And languages and practices evolve as people gain more experience so early practices should

Re: [go-nuts] [ANN] fixed point math library

2018-11-30 Thread Bakul Shah
write verification code to avoid such mistakes. I was just musing that it sure would be nice to be able to have the compiler do such checking. > On Nov 29, 2018, at 7:59 PM, Ian Denhardt wrote: > > Quoting Bakul Shah (2018-11-29 22:13:45) > >> I doubt go2 will get generi

Re: [go-nuts] [ANN] fixed point math library

2018-11-29 Thread Bakul Shah
FWIW, in some code I am writing, I considered using fixed point decimal numbers but ended up defining a *currency* type which is an int64 for value + a separate unit + currency kind. Even if I use a unit of millicent, this will allow handling amounts close to $100 Trillion. I don't expect this

Re: [go-nuts] contracts thought experiment: dimension checks

2018-11-27 Thread Bakul Shah
On Nov 26, 2018, at 8:46 PM, Ian Lance Taylor wrote: > > On Mon, Nov 26, 2018 at 5:14 PM Dan Kortschak > wrote: >> >> >> Question: >> >> One of the areas where we do this is in the mat package for matrix >> arithmetic and linear algebra. We use panics in lieue of a compile-time >> type check

Re: [go-nuts] go language sensitive editor?

2018-11-21 Thread Bakul Shah
On Nov 20, 2018, at 12:52 PM, Pat Farrell wrote: > > I know, this is both a FAQ and an unanswerable question. I'm an old > programmer who has used nearly every editor known to man. I am not a fan of > whole-universe IDEs, but can use them. I also speak vi/vim pretty fluently. > > What editors

Re: [go-nuts] [ANN] Koazee a library inspired by functional programming and lazy evaluation that takes the hassle out of working with arrays

2018-11-13 Thread Bakul Shah
On Nov 12, 2018, at 5:28 PM, robert engels wrote: > > You can pretty much look at the Java8 streams source (from OpenJDK) and port > it to Go. It would need to use interface{} or reflect - the former probably > being faster, but both wouldn’t have the type safety - but I think the code >

Re: [go-nuts] [ANN] Koazee a library inspired by functional programming and lazy evaluation that takes the hassle out of working with arrays

2018-11-12 Thread Bakul Shah
asically you are building unix like pipelines but they are typed and you are not constrained by shell syntax. This will be non-trivial but can be a very useful package. > > El lunes, 12 de noviembre de 2018, 12:17:12 (UTC+1), Bakul Shah escribió: > On Nov 11, 2018, at 11:27 AM, Iván Corrales S

Re: [go-nuts] [ANN] Koazee a library inspired by functional programming and lazy evaluation that takes the hassle out of working with arrays

2018-11-12 Thread Bakul Shah
On Nov 11, 2018, at 11:27 AM, Iván Corrales Solera wrote: > > Hey guys, last weeks I've been working on Koazee and I just released a very > first version Titi, v0.0.1 . > > Koazee is a golang library inspired in Lazy evaluation and functional > programming that provides us a rich set of

Re: [go-nuts] Understanding the doc (why can't I?)

2018-10-15 Thread Bakul Shah
On Mon, 15 Oct 2018 21:29:07 -0600 andrey mirtchovski wrote: > > Unlikely :-) > > > > The following is much less obscure. > > > > func Shuffle(slice inteface{}) > > > > & might have more more sense. e.g. > > > > var cards []card > > ... > > rand.Shuffle(cards) > >

Re: [go-nuts] Understanding the doc (why can't I?)

2018-10-15 Thread Bakul Shah
On Mon, 15 Oct 2018 20:39:11 -0600 andrey mirtchovski wrote: > > May be it ought to be called FYShuffle? > > then we'ld have to rename it if we switched the algorithm (which has > happened once for sort.Sort already). that's not what go is about :) Unlikely :-) The following is much less

Re: [go-nuts] Understanding the doc (why can't I?)

2018-10-15 Thread Bakul Shah
On Oct 15, 2018, at 6:44 PM, Neil Higgins <1955ne...@gmail.com> wrote: > > Ok, Dan. With what you have told me, I acknowledge that shuffling is what > it’s all about, so the metaphysics matches the physics on this case. So the > problem is on my side: Probably a deficit in fluency with

Re: [go-nuts] Traverse directory without infinite loops while following symlinks

2018-10-08 Thread Bakul Shah
On Mon, 08 Oct 2018 11:51:59 +0100 roger peppe wrote: > On 8 October 2018 at 08:53, Rob Pike wrote: > > Actually the original is a paper: > > https://www.cs.cmu.edu/~crary/819-f09/Hoare78.pdf > > The book came later and is substantially different although not > > contradictory. Channels were not

Re: [go-nuts] why does go reverse the order of name and type? "i int" vs "int i"

2018-09-20 Thread Bakul Shah
On Wed, 19 Sep 2018 22:30:11 -0700 Sathish VJ wrote: > > I've been asked this question a few times and I haven't been able to find > an answer. Why does go reverse the order of variable declaration: "i int" > vs "int i" > > Is there anything in the language design that requires this or was it

Re: [go-nuts] Scrapping contracts (was: "Generics as bultin typeclasses")

2018-09-11 Thread Bakul Shah
On Sep 11, 2018, at 3:02 PM, Ian Lance Taylor wrote: > > I'll just note briefly that I tossed field accessors in the contracts > design draft because it was easy, not because I thought it was an > important feature. It would be interesting to see a real use case for > it. At this point I would

Re: [go-nuts] Link: Getting specific about generics

2018-09-02 Thread Bakul Shah
> On Sep 2, 2018, at 3:19 PM, roger peppe wrote: > > > > On Sun, 2 Sep 2018, 5:09 pm Bakul Shah, <mailto:ba...@bitblocks.com>> wrote: > People may find this excellent paper “Datatype-Generic Programming” by Jeremy > Gibbons useful in this discussion

Re: [go-nuts] Link: Getting specific about generics

2018-09-02 Thread Bakul Shah
People may find this excellent paper “Datatype-Generic Programming” by Jeremy Gibbons useful in this discussion. It’s 72 pages long. https://www.cs.ox.ac.uk/jeremy.gibbons/publications/dgp.pdf I want generics but I still don’t know if I like this go2 generics proposal. At least as an exercise

Re: [go-nuts] golang maps; using slice as a key

2018-05-23 Thread Bakul Shah
On Wed, 23 May 2018 00:25:49 -0700 Karan Chaudhary wrote: > > One other simpler (and not so elegant) solution is to use separate set for > each element. > > https://play.golang.org/p/9ZSRfAyOX4- > > @Bakul's solution sounds good but haven't tried to understand it clearly.

Re: [go-nuts] golang maps; using slice as a key

2018-05-22 Thread Bakul Shah
On Tue, 22 May 2018 10:59:24 -0700 Sankar wrote: > > Is there a way to use a slice as a key to a map ? If I try, I get a > compilation error: `invalid map key type`. > > I tried creating a custom type, which contains an array as the element. > However, I could not

Re: [go-nuts] Checking IP against CIDR ranges

2018-05-15 Thread Bakul Shah
On Tue, 15 May 2018 17:38:26 -0700 XXX ZZZ wrote: XXX ZZZ writes: > > I'm trying to check an IP against a list of several CIDR ranges, so far the > most obvious way to do it seems to parse both the IP and the cidr ranges ( > ParseCIDR) and then do a net.contain()

Re: [go-nuts] Re: dynamic programming or something else

2018-05-15 Thread Bakul Shah
The O(lg n) recursion with memorization algorithm for computing fib(n) can be directly derived from its formula by repeated application of it. f(n)= f(n-1)+f(n-2)= 2*f(n-2)+f(n-3)=f(2)*f(n-2)+f)1)*(n-3)= 3*f(n-3)+2*f(n-4)=f(3)*f(n-3)+f(2)*f(n-4)= and so on until you reach an expression built

Re: [go-nuts] Re: Go could really use a while statement

2018-05-10 Thread Bakul Shah
On Thu, 10 May 2018 15:02:39 - Michael Jones wrote: > > Maybe the central issue here has been lost because of the confusion between > English words and the keywords of various languages. Let's be explicit: *a > controlled looping construct may test the control

Re: [go-nuts] Cyclic types

2018-05-09 Thread Bakul Shah
I think it is more than a matter of "eager" vs "on-demand" computation. T{} can't be constructed until its size is known. Semantically this is a recursive definition. However, a human may falsely assume that T{} is constructable and given that they may think len(T{}.a) can be computed. If on the

Re: [go-nuts] Re: Go could really use a while statement

2018-05-03 Thread Bakul Shah
On Thu, 03 May 2018 20:46:59 -0700 Lucio wrote: > > I never felt the need to join an APL fan club, but you sure tempt me, Bakul! > > Is there one, or do we need to start one? What would be the minimal entry > qualification? There are some mailing lists and websites that

Re: [go-nuts] Re: Go could really use a while statement

2018-05-03 Thread Bakul Shah
Perhaps you mean “the functional side has done away with loops” or “made do with recursion”? I still remember that as a newbie I was confused about while loops but not recursion. I thought that the while was being *continuously* monitored during the entire execution of the while and not just

Re: [go-nuts] Re: Go could really use a while statement

2018-05-02 Thread Bakul Shah
On Wed, 02 May 2018 03:04:38 -0700 Lucio wrote: > > E.J. Dijkstra in "A Discipline of Programming" proposed multicase "do" and > "if" constructs; the former looping, the latter single-shot. The "guards" > he proposed were strictly boolean expressions determining which, if

Re: [go-nuts] Beginner question about interface

2018-04-28 Thread Bakul Shah
On Apr 27, 2018, at 11:56 PM, k1atti...@gmail.com wrote: > > I want to search in all library (which have source code) > Maybe i don't understand the concept of Golang (I have delphi,c++,c > background) > > > for exmaple : > I see this. This function need an interface type : r > func

Re: [go-nuts] Type func binding and interfaces

2018-04-25 Thread Bakul Shah
Roger is right. A heap can be a good structure for a priority queue but not for search. That is because it is partially ordered and siblings are not in any sorted order. In any case heaps are typically implemented with a vector. Go already has a pkg for it. go doc heap. Seems like you’re doing

Re: [go-nuts] binary tree. different results on linux 64 and windows 32 machines.

2018-04-19 Thread Bakul Shah
Terminate Scanf format strings with \n. To see why, do "go doc fmt.Scanf". Always check the result of (at least) any input operation such as Scanf. > On Apr 19, 2018, at 10:31 AM, Alex Dvoretskiy wrote: > > Hello Golang-nuts, > > Following code reads data from file

Re: [go-nuts] Goroutines, Nonblocking I/O, And Memory Usage

2018-03-15 Thread Bakul Shah
On Wed, 14 Mar 2018 12:37:22 -0700 Ian Lance Taylor wrote: Ian Lance Taylor writes: > On Wed, Mar 14, 2018 at 11:58 AM, Rio wrote: > > > > While implementing a SOCKS proxy in Go, I ran into an issue which is better > > explained in details by Evan Klitzke in

Re: [go-nuts] fast small prime checker

2018-03-04 Thread Bakul Shah
> On Mar 4, 2018, at 1:40 PM, Bakul Shah <ba...@bitblocks.com> wrote: > > >> On Mar 4, 2018, at 12:43 PM, ralphdoncas...@gmail.com wrote: >> >> I am curious to see how you implemented the table lookup. Is the code >> posted somewhere? > > Th

Re: [go-nuts] fast small prime checker

2018-03-04 Thread Bakul Shah
> On Mar 4, 2018, at 12:43 PM, ralphdoncas...@gmail.com wrote: > > I am curious to see how you implemented the table lookup. Is the code posted > somewhere? This should easy. Check all odd numbers against primes <= square root of the candidate number and if prime, add it to primes list.

Re: [go-nuts] Channels vs Actors

2018-03-04 Thread Bakul Shah
Messages get sent to an actor's address and only that actor “reads” from that mailbox. And there is no buffering. Channels don’t run any logic (like an actor), they may be buffered and any goroutine with access to a channel may read from it. All goroutines run in the same address space. As actors

Re: [go-nuts] Is this a bug?

2018-02-25 Thread Bakul Shah
On Sun, 25 Feb 2018 09:25:42 + Jan Mercl <0xj...@gmail.com> wrote: Jan Mercl writes: > --f4f5e808e63ceebaa7056605faf5 > Content-Type: text/plain; charset="UTF-8" > > On Sun, Feb 25, 2018 at 10:23 AM Bakul Shah <ba...@bitblocks.com> wrote: > > > Why

Re: [go-nuts] Is this a bug?

2018-02-25 Thread Bakul Shah
On Sun, 25 Feb 2018 01:01:08 -0800 Dave Cheney wrote: Dave Cheney writes: > --=_Part_12529_340231507.1519549268925 > Content-Type: text/plain; charset="UTF-8" > > Type C conforms to the T1 interface? > > What did you expect? C conforms to both T1 and T2. var x2 T2

[go-nuts] Is this a bug?

2018-02-25 Thread Bakul Shah
https://play.golang.org/p/IMWd3cvgfsU // also replicated below package main import ( "fmt" ) type ( T1 interface{ f1()int; f2()int } T2 interface{ f2()int; f3()int } ) type C int func (c C)f1()int {return 1} func (c C)f2()int {return 2} func (c C)f3()int {return 3}

Re: [go-nuts] Appreciating Go

2018-02-24 Thread Bakul Shah
afe. > > That doesn't mean that I don't think sum types are a decent idea, but > just that I'm not sure that they're as clear a win for this (a > commonly cited use case) as one might think. > > cheers, >rog. > > >> On 24 February 2018 at 01:23, Bakul S

Re: [go-nuts] Appreciating Go

2018-02-23 Thread Bakul Shah
On Fri, 23 Feb 2018 17:39:16 -0800 Ian Lance Taylor <i...@golang.org> wrote: Ian Lance Taylor writes: > On Fri, Feb 23, 2018 at 5:23 PM, Bakul Shah <ba...@bitblocks.com> wrote: > > > > I once worked out some details of adding sum types to Go and I > > think it is q

Re: [go-nuts] Appreciating Go

2018-02-23 Thread Bakul Shah
On Thu, 22 Feb 2018 12:55:01 + Jesper Louis Andersen wrote: > > For sums, in Go, I have to return a pair, > > x, err := someOperation(..) > > but this is slightly inconsistent, insofar I can return "nil, nil", which > might not be a valid value, or I can

BSD Re: [go-nuts] Experience report on coming to Go from a C perspective

2018-02-22 Thread Bakul Shah
On Feb 22, 2018, at 2:16 PM, Devon H. O'Dell <devon.od...@gmail.com> wrote: > > (Re-adding list in here with Bakul's okay.) > > 2018-02-22 12:27 GMT-08:00 Bakul Shah <ba...@bitblocks.com>: >> On Thu, 22 Feb 2018 12:02:35 -0800 "Devon H. O'Dell" <d

  1   2   >