Re: [go-nuts] Failure in file seek

2024-04-08 Thread 'Bakul Shah' via golang-nuts
> offset, err := f.Seek(0, 10) The second argument needs to be one of io.{SeekStart,SeekCurrent,SeekEnd} (0, 1 or 2). go doc os.File.Seek > On Apr 8, 2024, at 2:24 PM, Nikhilesh Susarla wrote: > > github/file-seek/main.go >

Re: [go-nuts] Any interest in nat.mulRange simplification/optimization?

2024-01-13 Thread Bakul Shah
orward. It's free of any clever >> multiplication algorithms or mathematical delights. It could easily be >> giving up 10x or more for that reason alone. And I haven't even profiled it >> yet. >> >> -rob >> >> >> On Sat, Jan 13, 2024

Re: [go-nuts] Any interest in nat.mulRange simplification/optimization?

2024-01-13 Thread Bakul Shah
allelization. > > -rob > > > On Tue, Jan 9, 2024 at 4:54 PM Bakul Shah <mailto:ba...@iitbombay.org>> wrote: >> For that you may wish to explore Peter Luschny's "prime swing" factorial >> algorithm and variations! >> https://oeis.

Re: [go-nuts] Any interest in nat.mulRange simplification/optimization?

2024-01-08 Thread Bakul Shah
M, Rob Pike wrote: > > Here's an example where it's the bottleneck: ivy factorial > > > !1e7 > 1.20242340052e+65657059 > > )cpu > 1m10s (1m10s user, 167.330ms sys) > > > -rob > > > On Tue, Jan 9, 2024 at 2:21 PM Bakul Shah <mailto:

Re: [go-nuts] Any interest in nat.mulRange simplification/optimization?

2024-01-08 Thread Bakul Shah
Perhaps you were thinking of this? At iteration number k, the value xk contains O(klog(k)) digits, thus the computation of xk+1 = kxk has cost O(klog(k)). Finally, the total cost with this basic approach is O(2log(2)+¼+n log(n)) = O(n2log(n)). A better approach is the binary splitting : it just

Re: [go-nuts] Can we not invoke methods on types referring to generics?

2023-10-19 Thread Bakul Shah
On Oct 19, 2023, at 9:02 PM, Nurahmadie Nurahmadie wrote: > > Is it not possible to have both _auto_ downcasting and new method binding to > work in Go? What you are suggesting may make things more *convenient* but at the same time the potential for accidental mistakes goes up. The key is find

Re: [go-nuts] Generic "nillable" constraint

2023-10-17 Thread Bakul Shah
I'd happy with if val { ... } and if !val { ... } Instead of comparing val with an explicit zero but don't feel strongly about this. > On Oct 17, 2023, at 9:09 PM, Jon Watte wrote: > > Circling back to this, because it came up today again. > > Here's the generic function I

Re: [go-nuts] Why causes []any trouble in type equations?

2023-10-11 Thread Bakul Shah
On Oct 11, 2023, at 11:09 AM, Torsten Bronger wrote: > > Then, all boils down to the fact that you can’t pass []float64 as an > []any. To be honest, I still don’t fully understand why this is > forbidden, so I just accept that the language does not allow it. I think in the first case []any is

Re: [go-nuts] no way to pause `Listen` on net connections

2023-07-23 Thread Bakul Shah
You can do a non-blocking select on a channel prior to l.Accept(). If there is a pause message, you do a blocking select on the same channel for an resume or finish message. A separate goroutine can send you those messages depending on conditions under which you want to pause or resume. If the

Re: [go-nuts] memory safe languages question

2023-07-23 Thread Bakul Shah
The NSA paper says Some examples of memory safe languages are C#, Go, Java, Ruby™, and Swift® Note "Some"; it is not an exhaustive list of memory safe languages. Presumably these languages are mentioned b

Re: [go-nuts] Go routines consuming memory

2023-06-06 Thread Bakul Shah
You should read the comments following the article you referenced. In addition there is a long thread on hackernews that might be worth browsing: https://news.ycombinator.com/item?id=36024209 But if you want a real insight into how concurrent programs behave, you are better off writing your own

Re: [go-nuts] Short Variable Declarations Are Oversold

2023-04-22 Thread Bakul Shah
If you are not using an IDE, you can always use, for example, "go doc os.Open" to see what os.Open returns. For user packages, you can use for example "go doc github.com/benhoyt/goawk/parser.ParseProgram" from your directory that contains "go.mod" for your program. > On Apr 22, 2023, at 3:31 P

Re: [go-nuts] Interesting "select" examples

2023-04-07 Thread Bakul Shah
> On Apr 4, 2023, at 6:20 AM, Jesper Louis Andersen > wrote: > > On Tue, Apr 4, 2023 at 2:22 AM Nigel Tao > wrote: >> >> I'd have to study mux9p for longer, but its select chooses between two >> receives, so it could possibly collapse to a single heterogenous >> c

Re: [go-nuts] Upgradable RLock

2023-02-04 Thread Bakul Shah
You can implement your own multiple-reader-single-writer-lock using what Go gives you. For example: https://eli.thegreenplace.net/2019/implementing-reader-writer-locks/ > On Jan 30, 2023, at 4:42 PM, Robert Engels wrote: > > Yes but only for a single reader - any concurrent reader is going to

Re: [go-nuts] Guaranteeing deterministic execution of Golang code

2023-01-16 Thread Bakul Shah
I would think the map iteration order is arbitrary but deterministic. That is, the same set of keys will be iterated the same way every time. This is not the case with the select statement. > On Jan 16, 2023, at 1:34 AM, 'Axel Wagner' via golang-nuts > wrote: > > I think the question of "when

Re: [go-nuts] Re: Unicode variable name error

2022-11-06 Thread Bakul Shah
In Indic scripts in certain contexts you have to use a vowel sign for the typography to make sense; you can’t use a vowel letter in its place. So for example the middle “ku” in my name has to be written as ક+ુ — which will be rendered as કુ — even though it is equivalent to ક+્+ઉ. Also, “halant” (્

Re: [go-nuts] Error Handling Question

2022-10-25 Thread Bakul Shah
On Oct 25, 2022, at 2:28 PM, 'Daniel Lepage' via golang-nuts wrote: > > In contrast, the modern Go version buries the "normal" flow in a pile of > error handling, and IMO is a lot harder to follow: > > foo, err := Foo() > if err != nil { > return fmt.Errorf("enforcing foo limit: %w", err)

Re: [go-nuts] behavior of %f

2022-10-10 Thread Bakul Shah
On Oct 10, 2022, at 5:40 PM, Dante Castagnoli wrote: > > Also, if you were to take an int(f), you will note that it returns "0", and > not "1". %0.3f does *rounding*, while int(f) does *truncation*. 1.0 is closer to 0.... than 0.999 is to 0.... -- You received this message because yo

Re: [go-nuts] Go routine context

2022-09-30 Thread Bakul Shah
Quoting from this article: "Virtual threads (JEP 425 ) make it cost-effective to dedicate a thread to every such I/O operation, but managing the huge number of threads that can result remains a challenge." My quick take: may be this is due to "old thread think" as

Re: [go-nuts] Go routine context

2022-09-30 Thread Bakul Shah
I did a quick read. Virtual threads seems much *closer* to goroutines and they suggest people "unlearn" the overuse of thread local storage (TLS)! The thread pooling they talk about is to avoid the much higher thread creation time -- not a problem in Go. > On Sep 30, 2022, at 9:08 PM, Rob Pike

Re: [go-nuts] Is Go a security malware risk?

2022-08-23 Thread Bakul Shah
Doesn't this article in fact argue that it is the *security teams* that have to get smarter about what kind of threads they will be faced with and figure out how to deal with them? > On Aug 22, 2022, at 6:15 AM, 'Gopher-Insane' via golang-nuts > wrote: > > Hi > > So our security team has rai

Re: [go-nuts] Elementary Question About Calling Functions in Different Packages

2022-06-11 Thread Bakul Shah
On Jun 10, 2022, at 8:47 PM, jlfo...@berkeley.edu wrote: > > One hack solution I came up with to break cycles when Package A depends on > Package B which depends on Package A is to > create a symbolic link in Package A to the file(s) in Package B that > contain(s) the resources needed by Packa

Re: [go-nuts] Which is the most efficient way to read STDIN lines 100s of MB long and tens of MB info is passed to it

2022-05-08 Thread Bakul Shah
On May 7, 2022, at 1:24 PM, Constantine Vassilev wrote: > > I need to write a program that reads STDIN and should output every line that > contains a search word "test" to STDOUT. > > How I can test that considering the problem is a line can be 100s of MB long > (\n is line end) and tens of M

Re: [go-nuts] Add comparisons to all types

2022-05-03 Thread Bakul Shah
On May 3, 2022, at 7:27 PM, Ian Lance Taylor wrote: > > Does a program like this print true or false? > > func F() func() int { return func() int { return 0 } } > func G() { fmt.Println(F() == F()) } > > What about a program like this: > > func H(i int) func() *int { return func() *int { retur

Re: [go-nuts] Tacit Golang?

2022-04-02 Thread Bakul Shah
If I understand you right, you seem to want to use "<-" as the "compose" higher order function but as an infix operator. That is, instead of "value := F(G(args...))", you want to be able to write "value := (F <- G)(args...)". Further, "F <- G <- H" means "F <- (G <- H)". F, G &H are functions su

Re: [go-nuts] Why, oh why, do people do this? Things that annoy me in Go code.

2022-03-07 Thread Bakul Shah
GoBOL, anyone? > On Mar 7, 2022, at 2:20 PM, Rob Pike wrote: > > It could have been > > interface > UnreceivedMasterOrdersInterfaceThatCanBeUsedToCallGetUnreceivedByProductsWarehouseAndCompany > > Seriously, though, your example isn't even on the same planet as some > of the examples I've see

Re: [go-nuts] Data Structure for String Interning?

2022-01-09 Thread Bakul Shah
tom string representation containing uint32 > offset and length. This may or may not be faster than the map implementation, > but it will occupy less space, but with a single large object in memory. > > On Sun, Jan 9, 2022 at 5:35 PM Bakul Shah <mailto:ba...@iitbombay.org>> wrote:

Re: [go-nuts] Data Structure for String Interning?

2022-01-09 Thread Bakul Shah
The string header will be 16 bytes on 64bit word size machines. If most of the words are much shorter, interning won’t buy you much. For applications where you *know* all the words are short, and the total string space won’t exceed 4GB, you can try other alternatives. For instance if the max length

Re: [go-nuts] Managing perpetually running goroutines

2021-09-01 Thread Bakul Shah
Suggest you look at https://go.dev/blog/pipelines And check out the two videos recommended at the end of this article. Lots of interesting articles in the blog for you to chew on! -- Bakul > On Sep 1, 2021, at 2:55 PM, sanyia.said...@gmail.com wrote: > > Thanks Bryan, especially for the code ex

Re: [go-nuts] Golang language specification Document: Composite Literals example is not understandable

2021-06-22 Thread Bakul Shah
If you are familiar with C99’s designated initializers, this is similar but less general and less confusing. > On Jun 22, 2021, at 8:40 AM, Vaibhav Maurya wrote: > Hi, > > Please help me to understand the following syntax mentioned in the Golang > language specification document. > > https:/

Re: [go-nuts] Representing Optional/Variant Types Idiomatically (or not)

2021-06-17 Thread Bakul Shah
On Jun 17, 2021, at 1:20 AM, Jan Mercl <0xj...@gmail.com> wrote: > > On Thu, Jun 17, 2021 at 9:43 AM Joshua wrote: > >> 1) I'm modelling a data type which has a field which may or may not be >> there, would most Gophers reach for a pointer here, and use `nil' to >> represent a missing value

Re: [go-nuts] Still "missing" priority or ordered select in go?

2021-05-05 Thread Bakul Shah
On May 5, 2021, at 9:55 AM, Øyvind Teig wrote: > > Here is my cognitive test case. It is not 100% realistic, but it's just to > convey my point: > hiPri is a disconnect message of a smoke detetector. loPri is a fire alarm. > If the disconnect hiPri is activated before (1 sec to 1 ns) or simulat

Re: [go-nuts] rationale for math.Max(1, math.NaN()) => math.NaN()?

2021-04-26 Thread Bakul Shah
>From the wikipedia article: There are differences of opinion about the proper definition for the result of a numeric function that receives a quiet NaN as input. One view is that the NaN should propagate to the output of the function in all cases to p

Re: [go-nuts] [ANN] star-tex: a Go engine for TeX

2021-02-21 Thread Bakul Shah
On Feb 21, 2021, at 9:14 AM, Sebastien Binet wrote: > > On Sun Feb 21, 2021 at 17:46 CET, Patrick wrote: >> Hi Sebastien, >> >> that was a manual translation of the web file. >> My plan was to do more than that, ... TeX is such a beast. > > yeah... "how hard would it be to translate ~20k lines

Re: [go-nuts] Advice, please

2021-01-18 Thread Bakul Shah
On Jan 18, 2021, at 4:39 AM, Kevin Chadwick wrote: > > On 1/17/21 4:46 PM, Bakul Shah wrote: >> I’d be tempted to just use C for this. That is, generate C code from a >> register >> level description of your N simulation cores and run that. That is more or >> less

Re: [go-nuts] Advice, please

2021-01-17 Thread Bakul Shah
I’d be tempted to just use C for this. That is, generate C code from a register level description of your N simulation cores and run that. That is more or less what “cycle based” verilog simulators (used to) do. The code gen can also split it M ways to run on M physical cores. You can also gener

Re: [go-nuts] Advice, please

2021-01-16 Thread Bakul Shah
You may be better off maintaining two state *arrays*: one that has the current values as input and one for writing the computed outputs. At "negtive" clock edge you swap the arrays. Since the input array is never modified during the half clock cycle when you compute, you can divide it up in N co

Re: [go-nuts] Generics, please go away!

2020-12-25 Thread Bakul Shah
On Dec 25, 2020, at 8:48 AM, Henrik Johansson wrote: > > Both Java and C++ has benefited greatly from generics and most of their > respective communities wouldn't want them gone. I am pretty sure that's what > will happen with Go as well. Can we leave it now before we go from > "corruption" to

Re: [go-nuts] multicasting with encoding/gob

2020-12-23 Thread Bakul Shah
I looked at your top level README.md to understand what you are doing. Do these players join at the same time or different times? If different times, that can explain corruption with MultiWriter. One suggestion is to use "bufio" to create a writer for the gob encoder out of a []byte buffer. Then

Re: [go-nuts] mount remote storage without FUSE

2020-11-26 Thread Bakul Shah
This may help: https://github.com/zargony/fuse-rs The kernel driver is provided by the FUSE project, the userspace implementation needs to be provided by the developer. fuse-rs provides a replacement for the libfuse userspace library between these two. This way, a developer can fully take advan

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

2020-09-10 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 thr

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 bac

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: > https://go2gop

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

2020-08-20 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 to

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 > Co

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 iter

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 b

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 pa

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-14 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 http.R

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
o handle the > hypothetical _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

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 se

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 and

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 gi

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 comm

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 > betwee

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 with:

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 havin

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 Unf

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 variadi

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 bac

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 ha

[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 16

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

2019-07-11 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 the

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
at is sound advice. I've actually been debugging this on and off for > a couple months now, 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 a

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

2019-07-01 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 o

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 > multip

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 s

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

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 gener

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

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 would

Re: [go-nuts] Pointer declaration syntax

2019-03-12 Thread Bakul Shah
On Tue, 12 Mar 2019 21:16:21 -0700 Lucio wrote: > > On Monday, 11 March 2019 04:55:26 UTC+2, Rob 'Commander' Pike wrote: > > > > > > Whether a pointer should be declared with & or * or "ptr" or anything else > > is an arbitrary decision made the way it was by the Go designers because, > > as Ian

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] Channel Feature Suggestion

2019-02-21 Thread Bakul Shah
Sounds like you are talking about managing the number of goroutines processing a channel of requests. If there are far too many requests, you want to start up more, if the queue is almost empty, you want to shut them down. You can achieve that by just looking at len(ch). If len(ch) > some threshold

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? Nitpicking:

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 options,

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 languag

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 is

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 m

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 cla

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 :) G

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 an

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 gro

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 (a

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. An

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 doesn'

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 a

Re: [go-nuts] Pure functions and Go2

2018-12-14 Thread Bakul Shah
f doing 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:

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. Scheme

Re: [go-nuts] Package Stutter

2018-12-03 Thread Bakul Shah
l 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 foot

  1   2   3   >