Re: [go-nuts] Static assert at compile time

2018-10-27 Thread David Collier-Brown
In the special case of versioning, think about implementing "updaters" or 
"downdaters" on receipt of a versioned object/struct, as 
in 
https://leaflessca.wordpress.com/2017/02/12/dll-hell-and-avoiding-an-np-complete-problem/

For other uses, if you describe them here, we might be able to make a 
useful suggestion or two.

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


Re: [go-nuts] Static assert at compile time

2018-10-27 Thread hay
Hi robert, I'm looking for something C/C++ like static assertion to check 
few things at compile time.

Hi Ian, thanks for the reply. It is checking at init at the moment.

It is basically string or/and version checks. I'll give simple example. In 
C++ it will be something like this.


class Foo
{
public: 
static const string bar = "bar-version-01";
};

static_assert(Foo::bar != "bar-version-01", "Foo::bar version not same :(");


Above code will not compile if Foo::bar is different.

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


Re: [go-nuts] Static assert at compile time

2018-10-27 Thread Ian Denhardt
It's a little unclear to me what exactly you're trying to check; giving
an example might make it easier to advise.

But in any case, Go doesn't have anything quite like static_assert in
C/C++. Depending on what you're trying to do, you could put a call to
panic in an init() function, which would at least catch the error on
program start.

Quoting hay (2018-10-27 18:07:08)
>Hi,
>I've a project and it needs static asserts at compile time to check if
>string values are not left empty by the programmer. Is this possible in
>golang?
>Thanks in advance
>
>--
>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 [1]golang-nuts+unsubscr...@googlegroups.com.
>For more options, visit [2]https://groups.google.com/d/optout.
>
> Verweise
>
>1. mailto:golang-nuts+unsubscr...@googlegroups.com
>2. https://groups.google.com/d/optout

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


Re: [go-nuts] Static assert at compile time

2018-10-27 Thread robert engels
I don’t think it is possible in any language - I think it is a very of the 
halting problem https://en.wikipedia.org/wiki/Halting_problem 
 unless you are referring to 
checking a constant ?

> On Oct 27, 2018, at 5:07 PM, hay  wrote:
> 
> Hi,
> 
> I've a project and it needs static asserts at compile time to check if string 
> values are not left empty by the programmer. Is this possible in golang?
> 
> Thanks in advance
> 
> -- 
> 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 
> .

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