On Sun, Aug 20, 2017 at 4:34 PM, Tong Sun <suntong...@gmail.com> wrote:

> > You seem to refuse to answer even the simplest questions about your
> proposal, like "what's the difference to using pointers?".
>
> The answer lies exactly in your reply -- see how inconvenient it is
> currently, just to deal with a single variable,
>

I don't believe it's inconvenient at all. It seems to be pretty much
exactly the same level as convenience as the C# example. It seems you are
placing a much larger value on this slightly different syntax than I (or
any other programmer I know).

whereas, what I'm dealing with is,
>

> Think of dealing with a json string of several meg, which full of nullable
> ints.
>
> Moreover,
>
> *In C#, just by adding a "?" to the end of the type solves the problem. *
>
The difference is, once again, as I put in my OP: *it is** causing
> tremendous problems for me so far, as I have to jump over the hoops to deal
> with them. *
> *In C#, just by adding a "?" to the end of the type solves the problem. *
>

I mentioned an example above, where the Go version of the code is
significantly shorter than the C# version and has the equivalent
complexity. It seems to me, that it serves as a good prototype of how Go
can - today - already do what you are asking but that you are stubbornly
keeping to your specific syntax without giving any justification or example
of how it would improve things.


> I.e. it's all above convenient. I've repeated myself several times now,
> and I don't care if you get it or not any more. That's why
>
> This is the end of the discussion
>

Okay, that is fair (I mean. It's not "fair", but I can accept it).


>
> On Sun, Aug 20, 2017 at 10:21 AM, Axel Wagner <
> axel.wagner...@googlemail.com> wrote:
>
>> On Sun, Aug 20, 2017 at 4:08 PM, Tong Sun <suntong...@gmail.com> wrote:
>>
>>> The
>>>
>>> fmt.Println(unmarshal(`{"foo": 3}`))
>>>
>>> prints a pointer instead of 3.
>>>
>>
>> Yes, it is a pointer to an integer holding the value 3. If you want it to
>> format differently, implement fmt.Stringer.
>>
>>
>>>
>>> This is NOT what I'm asking for, despite what you think.
>>>
>>
>> I am aware. The difference is - again - one of syntax, which I described
>> as "a very marginal benefit, at best".
>>
>>
>>> I think any further explanation is pointless, since you disagree from
>>> the very first. It'll be fruitless trying to make you look from other's
>>> view.
>>>
>>> All I'm trying to do is to make a point. So far it is *inconvenient*,
>>> to deal with the situation I've described. Think of dealing with a json
>>> string of several meg, which full of nullable ints. It is doable, but your
>>> "*int" is not the solution.
>>>
>>
>> How, specifically, is "int?" better? Again, describe the semantics of
>> what you are actually *suggesting*. From what I can tell, the two are
>> mechanically and bijectively translatable into each other. Looking at this
>> example: https://stackoverflow.com/questions/2690866/what-
>> is-the-purpose-of-a-question-mark-after-a-type-for-example-int-myvariabl
>>
>> You'd write that in go as
>>
>> var num *int
>>
>> // Is the HasValue property true?
>> if num != nil {
>>       fmt.Println("num = " + *num)
>> } else {
>>       fmt.Println("num = Nil");
>> }
>>
>> // y is set to zero
>> var y int
>> if num != nil {
>>     y = *num
>> }
>>
>> // num.Value throws an InvalidOperationException if num.HasValue is false
>> defer func() {
>>     if v := recover(); v != nil {
>>         fmt.Println("panic:", v)
>>     }
>> }()
>> y = *num
>>
>> Yes, there obviously is a difference. But it is a very minor one.
>>
>>
>>> This is the end of the discussion.
>>>
>>
>> What discussion? You seem to refuse to answer even the simplest questions
>> about your proposal, like "what's the difference to using pointers?".
>>
>>
>>> And I'm only asking for consideration in my OP.
>>>
>>
>>>
>>>
>>> On Sun, Aug 20, 2017 at 9:45 AM, Axel Wagner <
>>> axel.wagner...@googlemail.com> wrote:
>>>
>>>> On Sun, Aug 20, 2017 at 3:21 PM, Tong Sun <suntong...@gmail.com> wrote:
>>>>
>>>>> On Sun, Aug 20, 2017 at 2:22 AM, Axel Wagner <
>>>>> axel.wagner...@googlemail.com> wrote:
>>>>>
>>>>> ii := new(int)
>>>>>> (*ii) = 3
>>>>>> (*ii)++
>>>>>>
>>>>>> Yes, it's not exactly the same syntax. It still demonstrates that
>>>>>> what you are suggesting creates, at best, very marginal benefit.
>>>>>>
>>>>>
>>>>> This is where I don't agree on.
>>>>>
>>>>> var ii *int
>>>>>>
>>>>>
>>>>> This is what you are suggesting, how to define the variable. I.e., *to
>>>>> replace "int?"*.
>>>>>
>>>>
>>>> Again, what you write as "int?", you write as "*int" instead. What you
>>>> describe as "int?" is a type, that can either contain an int, or nothing.
>>>> That is exactly what pointers do; they are either nil, or contain a
>>>> reference to an int.
>>>>
>>>>
>>>>>
>>>>> ii = 3
>>>>>>
>>>>>
>>>>> This is what I believe what will happen if I parse json '{"ii", 3}'
>>>>> into it,
>>>>>
>>>>
>>>> The semantics of particular packages is what they choose. In the case
>>>> of encoding/json, it does what you want: https://play.golang.org/
>>>> p/3XIimrd6RF
>>>>
>>>> or read 3 from DB into it.
>>>>>
>>>>
>>>> I don't know how database/sql behaves in this matter. I suspect to a
>>>> degree that depends on the driver. In any case, this is a library-problem,
>>>> not a language problem.
>>>>
>>>>
>>>>> If not, then you didn't do a good job explaining your point.
>>>>>
>>>>
>>>> You made a suggestion for a language change. I believe it is fair to
>>>> put the onus of explanation on you here. Both of what the expected benefits
>>>> of your proposal are and why the current semantics aren't enough.
>>>>
>>>> ii++
>>>>>
>>>>>
>>>>> This demonstrate how I can deal with a "int?" variable in C#.
>>>>>
>>>>
>>>> And I demonstrated how you can deal with a "*int" variable in Go in
>>>> exactly the same manner. I demonstrated that your suggestion seems to be
>>>> exactly that: That you want to write "ii++" instead of writing "(*ii)++". I
>>>> summarized that as "a very marginal benefit at best".
>>>>
>>>>
>>>>> So, all in all, you are either shooting without fully understand what
>>>>> I am asking, or don't understand what "int?" actually means in C#, or 
>>>>> both.
>>>>>
>>>>
>>>> Then explain better what you are asking for. I indeed don't know C#.
>>>> But I understand the ?-operator to be the equivalent of Maybe<T> in Haskell
>>>> or Option<T> in rust, the semantics of both I described above. Pointers are
>>>> providing the corresponding semantics for Go.
>>>>
>>>>
>>>>>
>>>>>
>>>>>> On Sun, Aug 20, 2017 at 8:00 AM, Tong Sun <suntong...@gmail.com>
>>>>>> wrote:
>>>>>>
>>>>>>> <sigh> I did. why there are always people assuming the other party
>>>>>>> they are talking to is just silly. <sigh>
>>>>>>>
>>>>>>> Anyway, this is what i got:
>>>>>>>
>>>>>>> var ii *int
>>>>>>> ii = 3
>>>>>>> ii++
>>>>>>>
>>>>>>> cannot use 3 (type int) as type *int in assignment
>>>>>>>
>>>>>>> invalid operation: ii++ (non-numeric type *int)
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>> On Sun, Aug 20, 2017 at 1:24 AM, Tyler Compton <xavi...@gmail.com>
>>>>>>> wrote:
>>>>>>>
>>>>>>>> I don't think it's immediately obvious what use cases this "int?"
>>>>>>>> proposal delivers that aren't covered by "*int". The encoding/json 
>>>>>>>> package
>>>>>>>> uses pointers to support null JSON values.
>>>>>>>>
>>>>>>>> As a more general point, when someone answers your question,
>>>>>>>> they're taking time out of their day to help you. I think it's 
>>>>>>>> reasonable
>>>>>>>> for the burden of proof to be put upon the asker, who is looking to 
>>>>>>>> others
>>>>>>>> for help.
>>>>>>>>
>>>>>>>> On Sat, Aug 19, 2017 at 9:28 PM Tong Sun <suntong...@gmail.com>
>>>>>>>> wrote:
>>>>>>>>
>>>>>>>>> Oh yeah? Are you sure what you are answering is what I'm asking?
>>>>>>>>>
>>>>>>>>> Please try to understand what people are asking before showing off
>>>>>>>>> yourself, or post concrete example to proof that you understand 
>>>>>>>>> correctly
>>>>>>>>> what people are asking.
>>>>>>>>>
>>>>>>>>> On Sat, Aug 19, 2017 at 4:02 PM, Axel Wagner <
>>>>>>>>> axel.wagner...@googlemail.com> wrote:
>>>>>>>>>
>>>>>>>>>> Go can do what you want today, just that it's spelled "*int".
>>>>>>>>>>
>>>>>>>>>> On Sat, Aug 19, 2017 at 6:01 PM, Tong Sun <suntong...@gmail.com>
>>>>>>>>>> wrote:
>>>>>>>>>>
>>>>>>>>>>> - "int?" will be a different type than "int". I.e., we know very
>>>>>>>>>>> well what we are sacrificing when we choose that type.
>>>>>>>>>>> - There is a demand there, json and/or sql. Denying it won't
>>>>>>>>>>> make it go away.
>>>>>>>>>>>
>>>>>>>>>>> (*Sorry to Jan, was sending to the wrong place*)
>>>>>>>>>>>
>>>>>>>>>>> On Sat, Aug 19, 2017 at 11:54 AM, Jan Mercl <0xj...@gmail.com>
>>>>>>>>>>> wrote:
>>>>>>>>>>>
>>>>>>>>>>>> On Sat, Aug 19, 2017 at 5:05 PM Tong Sun <suntong...@gmail.com>
>>>>>>>>>>>> wrote:
>>>>>>>>>>>>
>>>>>>>>>>>> > Suggesting C# type syntax like "int?" so as to take nil as
>>>>>>>>>>>> valid value.
>>>>>>>>>>>>
>>>>>>>>>>>> - As int is not a pointer type, what would nil int mean?
>>>>>>>>>>>>
>>>>>>>>>>>> - Are you willing to sacrifice extra storage for the additional
>>>>>>>>>>>> isNil information or do you prefer that int cannot represent
>>>>>>>>>>>> 2^(sizeof(int)*8) different values?
>>>>>>>>>>>>
>>>>>>>>>>>> - (xyproblem?) If you need the information like 'isValid', why
>>>>>>>>>>>> a separate bool [field] is not enough?
>>>>>>>>>>>>
>>>>>>>>>>>> --
>>>>>>>>>>>>
>>>>>>>>>>>> -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 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.
>>>>>>>>>
>>>>>>>>
>>>>>>>
>>>>>>
>>>>>
>>>>
>>>
>>
>

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

Reply via email to