On Sat, Aug 6, 2016 at 4:08 AM, T L wrote:
>
> If you carelessly change the value of a global variable in std lib, some
> hard found bugs will be created.
This is what you really want, and it is the reason I was talking about
immutable variables earlier.
In Go, a constant is created at compile t
On the other hand, I would like to see introduced some variant of slices
with immutable backing arrays (it will allocate a lot though to modify a
variable of that type) that would be comparable. That's a whole other topic
however. slices are a much more delicate concept.
On Saturday, August 6,
If you carelessly do anything, you can introduce bugs.
Also note that it is fairly easy in Go to construct immutable "values".
The only thing we do not have is immutable value holders (let in other
languages) which is a form of static single assignment at the language
level.
The concept of vari
On Saturday, August 6, 2016 at 6:04:00 PM UTC+8, atd...@gmail.com wrote:
>
>
>
> On Saturday, August 6, 2016 at 11:53:42 AM UTC+2, T L wrote:
>>
>>
>>
>> On Saturday, August 6, 2016 at 5:45:50 PM UTC+8, atd...@gmail.com wrote:
>>>
>>> No, I'm saying that the current implementation is two pointers
On Saturday, August 6, 2016 at 11:53:42 AM UTC+2, T L wrote:
>
>
>
> On Saturday, August 6, 2016 at 5:45:50 PM UTC+8, atd...@gmail.com wrote:
>>
>> No, I'm saying that the current implementation is two pointers.
>> The value is addressed by the second pointer. So you cannot really put a
>> const
On Saturday, August 6, 2016 at 5:39:51 PM UTC+8, Dave Cheney wrote:
>
> Interfaces don't describe data, they describe behaviour. If you don't want
> the behaviour to be changeable, use a concrete type.
>
There is the need to define many constant interface values of one special
interface type,
On Saturday, August 6, 2016 at 5:45:50 PM UTC+8, atd...@gmail.com wrote:
>
> No, I'm saying that the current implementation is two pointers.
> The value is addressed by the second pointer. So you cannot really put a
> const in an interface. (thought experiment)
>
> Of course, in the specific cas
No, I'm saying that the current implementation is two pointers.
The value is addressed by the second pointer. So you cannot really put a
const in an interface. (thought experiment)
Of course, in the specific case of boxing a value type, that could work. If
you accept that the *typ never changes
Interfaces don't describe data, they describe behaviour. If you don't want
the behaviour to be changeable, use a concrete type.
On Saturday, 6 August 2016 19:30:22 UTC+10, T L wrote:
>
>
>
> On Saturday, August 6, 2016 at 5:19:08 PM UTC+8, Dave Cheney wrote:
>>
>> Because an interface is a run ti
On Saturday, August 6, 2016 at 5:19:08 PM UTC+8, Dave Cheney wrote:
>
> Because an interface is a run time data structure, it cannot contain
> constants because they don't exist at run time.
>
I think an interface is not essential to be always a run time data
structure. If compiler thinks it i
Because an interface is a run time data structure, it cannot contain
constants because they don't exist at run time.
On Saturday, 6 August 2016 19:14:26 UTC+10, T L wrote:
>
>
>
> On Saturday, August 6, 2016 at 3:58:52 PM UTC+8, Dave Cheney wrote:
>>
>> It is not possible. Constants only exist at
On Saturday, August 6, 2016 at 3:58:52 PM UTC+8, Dave Cheney wrote:
>
> It is not possible. Constants only exist at compile time.
yes, but why constant interface values can't exist at compile time?
--
You received this message because you are subscribed to the Google Groups
"golang-nuts" g
On Saturday, August 6, 2016 at 4:06:07 PM UTC+8, atd...@gmail.com wrote:
>
> Possibily, if you freeze the type of things that can be boxed by the
> interface. But what would it be useful for ?
> That would just mean that an interface is constant. Not even that the
> value it wraps can't be chan
On Saturday, August 6, 2016 at 4:06:07 PM UTC+8, atd...@gmail.com wrote:
>
> Possibily, if you freeze the type of things that can be boxed by the
> interface. But what would it be useful for ?
> That would just mean that an interface is constant. Not even that the
> value it wraps can't be chan
Possibily, if you freeze the type of things that can be boxed by the
interface. But what would it be useful for ?
That would just mean that an interface is constant. Not even that the value
it wraps can't be changed (because with the current implementation, the
values an interface wraps need to
It is not possible. Constants only exist at compile time.
--
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 optio
Is it possible to make an interface constant if its concrete value type is
bool/number/string?
On Saturday, August 6, 2016 at 3:48:17 AM UTC+8, Ian Lance Taylor wrote:
>
> On Fri, Aug 5, 2016 at 11:21 AM, T L >
> wrote:
> >
> > For an interface value, its internal values will never change.
>
On Fri, Aug 5, 2016 at 11:21 AM, T L wrote:
>
> For an interface value, its internal values will never change.
> Are there any problems if golang supports constant interface values?
Pedantically, in Go, constants are untyped by default. It doesn't
make sense to speak of an untyped interface valu
For an interface value, its internal values will never change.
Are there any problems if golang supports constant interface values?
--
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,
19 matches
Mail list logo