Am Dienstag, 22. November 2016 22:16:27 UTC+1 schrieb Tong Sun:
>
> Hi,
>
> How to architect the OO's virtual function in Go?
>
>
Here is another blog that shows a way how to do this:
http://objectscape.blogspot.de/2013/09/inner-pattern-to-mimic-method.html
--
You received this message
I think you problem is here
jsonReservations, err :=
jsonConvert.ReservationsJson(otherReservations)
if err != nil {
rw.WriteHeader(http.StatusExpectationFailed)
fmt.Println(err)
}
Instead try this
if err != nil {
On Wednesday, November 23, 2016 at 8:21:23 PM UTC+5:30, Tong Sun wrote:
> I've tried to derive how to achieve a) implementation inheritance,
>> followed by b) type substitution and c) enabling dynamic dispatch as in
>> virtual functions in my blog post here:
>>
Hey im running a go server locally using gorilla mux and net/http.
For class we needed to create a room reservation system. I was testing the
application on multiple compyters on the same network but
when trying to create a reservation from both computer at the same time to
test concurrency I
On Wed, Nov 23, 2016 at 3:49 PM, roger peppe wrote:
> Ian, what you say is true, but is also true of types and other objects too,
> I think. I found some interesting anomalies playing around with the new
> plugin package.
We've worked hard to make sure that what I said
Let's just use https://github.com/google/pprof/issues/54 to avoid forking
the discussion?
On Wednesday, November 23, 2016 at 2:25:59 PM UTC-8, Dave Cheney wrote:
>
> Please raise an issue on the issue tracker, golang.org/issue/new
>
> On Thursday, 24 November 2016 09:11:30 UTC+11, Alexey
Ian, what you say is true, but is also true of types and other objects too,
I think. I found some interesting anomalies playing around with the new
plugin package.
Myself, I would have no objection to saying that two function values are
equal if they are defined by the same source code and use no
Hi Go team,
We've got a report for pprof tool where call frames for functions called
via reflection are not shown in the heap allocation profiles. The cause
turned out to be that all frames starting one matching "runtime\..*" regex
and its callees are pruned for heap profiles today.
As I said
before, Go's flavor of OO is different from that of other languages. Don't
try to map concepts one-to-one, or you will end up with very contrived
solutions. Always look at the big picture (why am I doing this?) and don't
get side-tracked by synthetic examples.
Most important is
On Friday, 18 November 2016 10:30:45 UTC-5, Ian Lance Taylor wrote:
>
> I think the book is trying to stress that it declares out but does not
> declare err. I agree that the sentence seems to imply that it does
> not assign a value to out, but in fact it does both declare out and
> assign a
On Wed, Nov 23, 2016 at 3:49 PM, Tong Sun wrote:
>
> On Wed, Nov 23, 2016 at 12:09 PM, Nick Patavalis wrote:
>
>> For this specific example, something like this:
>> https://play.golang.org/p/FsorWRaLKk
>>
>
> Thanks a lot Nick!
>
> I've simplified it a bit. Now it is:
>
> func (d Dog) Output() {
Great story and congrats on your project
On Wed, Nov 23, 2016, at 06:24 PM, Jeremy Echols wrote:
> *Project:*
>
> This one's been out a long time, but I wanted to get to a place where
> it felt solid before announcing it to this list. RAIS
>
On Wed, Nov 23, 2016 at 12:09 PM, Nick Patavalis wrote:
> For this specific example, something like this: https://play.golang.org/p/
> FsorWRaLKk
>
Thanks a lot Nick!
I've simplified it a bit. Now it is:
func (d Dog) Output() {
// Presumably complicated stuff, not re-implemented
Thanks Chad. This is beyond my understanding for the moment, but I'm sure
it'd be handy someday... Thanks.
On Wed, Nov 23, 2016 at 1:17 PM, wrote:
> Sorry, didn't read the whole thread, but here's how I tackled inheritance
> in my cross compiler:
That is the .net API; the equivalent C API is
https://msdn.microsoft.com/en-us/library/aa380261.aspx
Looking on godoc.org and github, I don't see any pre-made packages that
implement this. However, you can use golang.org/x/sys/windows to call this
function yourself.
*Project:*
This one's been out a long time, but I wanted to get to a place where it
felt solid before announcing it to this list. RAIS
(https://github.com/uoregon-libraries/rais-image-server) is CC0-licensed
and backs all the dynamic pan/zoom image-serving needs for Oregon Historic
Sorry, didn't read the whole thread, but here's how I tackled inheritance
in my cross compiler: https://play.golang.org/p/UDp7nSLyl2. Granted, I am
unsure about the unsafe thing, but the concept of a "method dispatcher" is
likely what you need.
On Wednesday, November 23, 2016 at 11:09:03 AM
On Wed, Nov 23, 2016 at 7:00 AM, T L wrote:
>
> On Wednesday, November 23, 2016 at 10:35:59 PM UTC+8, Axel Wagner wrote:
>>
>> So, your suggestion is, to have functions be comparable, but have the
>> comparisons always be false (unless compared to nil)? How would that be
>>
I am using the auto-generated google api client and ran in to a problem
with unsuspending a user (via admin/directory/v1). The Suspended field on
the User object has the json tab omitempty and setting Suspended to false
causes it not to get sent to the server. In my local copy of the library
And in case you want to actually marshal it into a struct, I recommend
giving JSON to Go a... go.
On Tuesday, 22 November 2016 20:48:49 UTC, vanmuld...@gmail.com wrote:
>
> I just started leaning Go and I've been stuck on this for a couple of days
>
> Running on an App Engine dev server
>
>
>
(note: I'm exiting this thread now. I believe at this point it's reasonably
clear, that there are good reasons for this and anyone not convinced yet
won't be convinced by further arguments anyway)
On Wed, Nov 23, 2016 at 6:30 PM, Axel Wagner
wrote:
> On Wed, Nov
On Wed, Nov 23, 2016 at 4:30 PM, T L wrote:
> If two functions do completely different things, they mus be two different
> functions.
>
No. An example has been given above, here is another one:
https://play.golang.org/p/uNN0G4gzFm
> Two different functions can also do the
On Wednesday, November 23, 2016 at 5:17:11 PM UTC+2, Tong Sun wrote:
>
> Can you make it work on play.golang.org, from this code
> https://play.golang.org/p/QjCtD9rGpa, according to your plan?
>
For this specific example, something like this:
https://play.golang.org/p/FsorWRaLKk
/npat
--
On Wed, Nov 23, 2016 at 6:00 PM T L wrote:
>
>
> On Thursday, November 24, 2016 at 12:06:43 AM UTC+8, Jan Mercl wrote:
>
> On Wed, Nov 23, 2016 at 4:55 PM T L wrote:
>
> > But we can't take addresses of formally declared functions and function
> literals.
On Thursday, November 24, 2016 at 12:06:43 AM UTC+8, Jan Mercl wrote:
>
> On Wed, Nov 23, 2016 at 4:55 PM T L
> wrote:
>
> > But we can't take addresses of formally declared functions and function
> literals.
>
> Yes, so if you cannot have the function pointer (like in
Hello everyone,
Does anyone know a Go package which provides an interface to the Windows Data
Protection API?
I am pretty much searching for the Go equivalent of this:
https://msdn.microsoft.com/en-us/library/system.security.cryptography.protecteddata(v=vs.110).aspx
On Wed, Nov 23, 2016 at 4:55 PM T L wrote:
> But we can't take addresses of formally declared functions and function
literals.
Yes, so if you cannot have the function pointer (like in func foo() {}; fp
:= foo) then there is nothing to compare so I don't understand what's
On Wednesday, November 23, 2016 at 11:47:19 PM UTC+8, Jan Mercl wrote:
>
> On Wed, Nov 23, 2016 at 4:28 PM T L
> wrote:
>
> > Predeclared functions, including inlined ones, can be viewed as
> constants, which have not addresses.
> > We can compare variable to constant,
On Wednesday, November 23, 2016 at 11:47:19 PM UTC+8, Jan Mercl wrote:
>
> On Wed, Nov 23, 2016 at 4:28 PM T L
> wrote:
>
> > Predeclared functions, including inlined ones, can be viewed as
> constants, which have not addresses.
> > We can compare variable to constant,
On Wednesday, November 23, 2016 at 11:28:13 PM UTC+8, T L wrote:
>
>
>
> On Wednesday, November 23, 2016 at 11:18:02 PM UTC+8, Jan Mercl wrote:
>>
>> On Wed, Nov 23, 2016 at 3:30 PM T L wrote:
>>
>> > Then?
>>
>> Then there is nothing to compare. If a function is inlined
On Wed, Nov 23, 2016 at 4:28 PM T L wrote:
> Predeclared functions, including inlined ones, can be viewed as
constants, which have not addresses.
> We can compare variable to constant, right?
Wrong.
Function pointers, specific Go implementation details aside for now, are
On Wednesday, November 23, 2016 at 11:11:24 PM UTC+8, Axel Wagner wrote:
>
> So, even though two functions do completely different things, you still
> want to have them equal? And even though two other functions do completely
> the same thing, they should be different?
>
If two functions do
Yes... so every specific animal type implements it's own Output() method,
which does the trivial IsA() part, and calls Animal's Output() for the
common complicated parts...
On Nov 23, 2016 16:35, "Tong Sun" wrote:
> Have you noticed the IsA() func call there?
>
> On Wed,
Oh, I think you might not have notice this request from OP:
Please think of the "func Output()" as a very complicated function that I
> only want to define *once *at the base level, not to duplicate into each
> sub classes.
On Wed, Nov 23, 2016 at 10:16 AM, Tong Sun
On Wed, Nov 23, 2016 at 3:30 PM T L wrote:
> Then?
Then there is nothing to compare. If a function is inlined then you cannot
have a function pointer to it (like in func foo() {}; f := foo). So fully
supporting comparing function pointers means disabling inlining of any
Can you make it work on play.golang.org, from this code
https://play.golang.org/p/QjCtD9rGpa, according to your plan?
On Wed, Nov 23, 2016 at 10:14 AM, Nick Patavalis
wrote:
> Yes... so every specific animal type implements it's own Output() method,
> which does the
So, even though two functions do completely different things, you still
want to have them equal? And even though two other functions do completely
the same thing, they should be different?
Can you give a good justification of that behavior? And do you really think
it won't confuse people like
On Wednesday, November 23, 2016 at 10:39:01 PM UTC+8, Volker Dobler wrote:
>
> Am Mittwoch, 23. November 2016 15:30:39 UTC+1 schrieb T L:
>>
>>
>>
>> On Wednesday, November 23, 2016 at 9:53:57 PM UTC+8, Volker Dobler wrote:
>>>
>>> Just one argument out of many: Closures.
>>> x := 3
>>> f1 :=
On Wednesday, November 23, 2016 at 10:35:59 PM UTC+8, Axel Wagner wrote:
>
> So, your suggestion is, to have functions be comparable, but have the
> comparisons always be false (unless compared to nil)? How would that be
> useful and *not* completely confusing? e.g. how would that not lead to
On Wed, Nov 23, 2016 at 8:52 AM, Tahir Hashmi wrote:
>
> I also like the approach suggested by Sebastien Binet. It's really neat in
> situations where you can get by without needing to override the base
> implementation (e.g. of Shape.Output()).
>
That it is only a partial solution -- I have a
Am Mittwoch, 23. November 2016 15:30:39 UTC+1 schrieb T L:
>
>
>
> On Wednesday, November 23, 2016 at 9:53:57 PM UTC+8, Volker Dobler wrote:
>>
>> Just one argument out of many: Closures.
>> x := 3
>> f1 := func() int {
>> return x
>> }
>> f2 := func() int { return 3 }
>> // Is f1 == f2 ?
>>
>> x
Have you noticed the IsA() func call there?
On Wed, Nov 23, 2016 at 4:05 AM, Nick Patavalis
wrote:
> Hi,
>
> In your *second* example, making Output() a method of Animal will work,
> since it uses only the members (fields) of Animal, and not the fields of
> specific
On Wednesday, November 23, 2016 at 9:53:57 PM UTC+8, Volker Dobler wrote:
>
> Just one argument out of many: Closures.
> x := 3
> f1 := func() int {
> return x
> }
> f2 := func() int { return 3 }
> // Is f1 == f2 ?
>
> x = 4
> // What now? Still f1 == f2? Or never equal?
>
>
Any bad to think
On Wednesday, November 23, 2016 at 9:45:56 PM UTC+8, Jan Mercl wrote:
>
> On Wed, Nov 23, 2016 at 2:40 PM T L
> wrote:
>
> Functions can be inlined.
>
> --
>
> -j
>
Then?
Is there any problem to think no two functions can be equal?
--
You received this message because
If functions are comparable you have to be very
careful in defining /when/ they are equal.
func f(x int)int {return x+2}
func g(x int)int {return x+2}
func h(x int)int {return x+1+1}
Are f and g equal? f and h?
func k() func (int)int { return func(int x)int {x + 1}}
Are k() and k() equal? f
Great responses. Thanks! I think what it comes down to is there's two main
definition/use cases of an interface:
- The inheritance-based one that you find in Java and C# where the
interface provides an contract into various implementations. The design
is typically API-driven and
Just one argument out of many: Closures.
x := 3
f1 := func() int {
return x
}
f2 := func() int { return 3 }
// Is f1 == f2 ?
x = 4
// What now? Still f1 == f2? Or never equal?
V.
--
You received this message because you are subscribed to the Google Groups
"golang-nuts" group.
To unsubscribe
I've tried to derive how to achieve a) implementation inheritance, followed
by b) type substitution and c) enabling dynamic dispatch as in virtual
functions in my blog post
here: https://tech.t9i.in/2014/01/22/inheritance-semantics-in-go/
I also like the approach suggested by Sebastien Binet.
On Wed, Nov 23, 2016 at 2:40 PM T L wrote:
Functions can be inlined.
--
-j
--
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
.
--
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.
I believe vet shadow is known to have issues and is quite picky ;-)
Your first one I'd say could be classed as bug as you're clearly
declaring n however I'd guess this is due to the for loop as declaring n
out of the loop eliminating the short declaration will fix it. This is
confirmed by
This is extremely common in go code, vet is being pedantic,
--
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
Hi,
In your *second* example, making Output() a method of Animal will work,
since it uses only the members (fields) of Animal, and not the fields of
specific animals (or any behavior that varies between animals). That's why
I'm insisting on *real* and *specific* examples, not synthetic ones.
53 matches
Mail list logo