Re: [go-nuts] Packages vs methods

2023-04-04 Thread 温博格
If one is using gopls for Go support for an IDE (like vscode), with
semantic tokens enabled, the two cases are colored differently. It's
incrementally cheap, as gopls already typechecks source.

[to enable in vscode: in settings, in the gopls section,
"ui.semanticTokens": true]

I don't know that this satisfies the request for 'an easy way'

On Tue, Apr 4, 2023 at 8:36 AM 'Axel Wagner' via golang-nuts
 wrote:
>
> This ist actually a syntactical difference. Both are syntactically just 
> selector expressions.
>
> So you'd need *semantic* highlighting, which not a lot of highlighters do. 
> One reason is performance and another is that it means highlighting might 
> fail for incorrectly typed (but syntactically valid) programs.
>
> And if one does, you can tell the difference between literally anything (on a 
> type level) - if you are willing to rely on highlighting to tell the 
> difference between an import and a variable, you can also use it to 
> differentiate between, say, an interface and a concretely typed variable. Or 
> an int and a float type. Or whatever.
>
> So in the context of the question, this strikes me as a pretty unhelpful 
> response. Yes obviously you can use a tool to *tell* you the difference by 
> performing a type check. But obviously the question was about a syntactical 
> way to do so.
>
> On Tue, Apr 4, 2023, 14:17 Reto  wrote:
>>
>> On Mon, Apr 03, 2023 at 10:19:49PM -0700, joseph.p...@gmail.com wrote:
>> > Is there an easy way to make
>> > this determination?
>>
>> Sure, use syntax highlighting in your favor.
>>
>> --
>> 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.
>> To view this discussion on the web visit 
>> https://groups.google.com/d/msgid/golang-nuts/mhisvutsz54nkickwqcxw4n2gqn3ccexnidng5i3p43qusxrkh%40tkbismvv64hz.
>
> --
> 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.
> To view this discussion on the web visit 
> https://groups.google.com/d/msgid/golang-nuts/CAEkBMfHVwhsrKjZNFWY3a4QukeJS_QP3hE%3DxF-aEKNt7GNZgQQ%40mail.gmail.com.

-- 
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.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/golang-nuts/CAOUkXSpVY%2Bq%3DHGsBZGj8T_brZFATcBL__bignJEaq9gAZdZswQ%40mail.gmail.com.


Re: [go-nuts] Packages vs methods

2023-04-04 Thread 'Axel Wagner' via golang-nuts
This ist actually a syntactical difference. Both are syntactically just
selector expressions.

So you'd need *semantic* highlighting, which not a lot of highlighters do.
One reason is performance and another is that it means highlighting might
fail for incorrectly typed (but syntactically valid) programs.

And if one does, you can tell the difference between literally anything (on
a type level) - if you are willing to rely on highlighting to tell the
difference between an import and a variable, you can also use it to
differentiate between, say, an interface and a concretely typed variable.
Or an int and a float type. Or whatever.

So in the context of the question, this strikes me as a pretty unhelpful
response. Yes obviously you can use a tool to *tell* you the difference by
performing a type check. But obviously the question was about a syntactical
way to do so.

On Tue, Apr 4, 2023, 14:17 Reto  wrote:

> On Mon, Apr 03, 2023 at 10:19:49PM -0700, joseph.p...@gmail.com wrote:
> > Is there an easy way to make
> > this determination?
>
> Sure, use syntax highlighting in your favor.
>
> --
> 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.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/golang-nuts/mhisvutsz54nkickwqcxw4n2gqn3ccexnidng5i3p43qusxrkh%40tkbismvv64hz
> .
>

-- 
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.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/golang-nuts/CAEkBMfHVwhsrKjZNFWY3a4QukeJS_QP3hE%3DxF-aEKNt7GNZgQQ%40mail.gmail.com.


Re: [go-nuts] Packages vs methods

2023-04-04 Thread Reto
On Mon, Apr 03, 2023 at 10:19:49PM -0700, joseph.p...@gmail.com wrote:
> Is there an easy way to make 
> this determination?

Sure, use syntax highlighting in your favor.

-- 
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.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/golang-nuts/mhisvutsz54nkickwqcxw4n2gqn3ccexnidng5i3p43qusxrkh%40tkbismvv64hz.


Re: [go-nuts] Packages vs methods

2023-04-04 Thread 'Axel Wagner' via golang-nuts
If you see `foo.bar()` it is definitely a method, as a package-scoped `bar`
function would not be exported so it would not be visible in other packages.
If, on the other hand, you see `foo.Bar()`, there is no easy way to tell.
You have to know if `foo` is a variable or a package in the given scope.

On Tue, Apr 4, 2023 at 7:20 AM joseph.p...@gmail.com <
joseph.p.mcguc...@gmail.com> wrote:

> When I’m reading go source and I see something like foo.bar(), my brain
> stutters for a second while I’m trying to determine if this is a reference
> to a package function or a receiver/method. Is there an easy way to make
> this determination?
>
> Thanks
>
> --
> 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.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/golang-nuts/e33c9734-4d83-4e21-9a95-b23be5e5a9bcn%40googlegroups.com
> 
> .
>

-- 
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.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/golang-nuts/CAEkBMfGP9yVmrNJqv9-5A%2Bir21bLd%3DS54OFXS%2Bej22TF__6xcw%40mail.gmail.com.