Rocksolid Light

News from da outaworlds

mail  files  register  groups  login

Message-ID:  

BOFH excuse #107: The keyboard isn't plugged in


comp / comp.lang.tcl / Re: Something odd with [oo::class create] on Tcl 8.6.13

SubjectAuthor
* Re: Something odd with [oo::class create] on Tcl 8.6.13Alan Grunwald
`- Re: Something odd with [oo::class create] on Tcl 8.6.13Ralf Fassel

1
Subject: Re: Something odd with [oo::class create] on Tcl 8.6.13
From: Alan Grunwald
Newsgroups: comp.lang.tcl
Organization: A noiseless patient Spider
Date: Tue, 28 May 2024 22:00 UTC
References: 1 2 3 4
Path: eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: nospam.nurdglaw@gmail.com (Alan Grunwald)
Newsgroups: comp.lang.tcl
Subject: Re: Something odd with [oo::class create] on Tcl 8.6.13
Date: Tue, 28 May 2024 23:00:31 +0100
Organization: A noiseless patient Spider
Lines: 67
Message-ID: <v35k78$pdgr$1@dont-email.me>
References: <usn9u8$3mlci$1@dont-email.me>
<87jzm8whs2.fsf@jmertens.eternal-september.org>
<ygav85ry9xs.fsf@panther.akutech-local.de> <usuhd1$1hjpd$1@dont-email.me>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit
Injection-Date: Wed, 29 May 2024 00:01:12 +0200 (CEST)
Injection-Info: dont-email.me; posting-host="cbee9ca3a05afd90d0ef63763747dc46";
logging-data="833051"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/K4EzquKNqem6K9to9gu/H39+hpQvGYqc="
User-Agent: Mozilla Thunderbird
Cancel-Lock: sha1:x05glXMK/tpUNVyc2T4lk5IHhGw=
In-Reply-To: <usuhd1$1hjpd$1@dont-email.me>
Content-Language: en-US
View all headers

On 14/03/2024 10:37, Alan Grunwald wrote:
> On 14/03/2024 09:52, Alan Grunwald wrote:
>> On 12/03/2024 11:19, Ralf Fassel wrote:
>>> * Joerg Mertens <joerg-mertens@t-online.de>
>>> | Alan Grunwald <nospam.nurdglaw@gmail.com> writes:
>>> | >     % oo::class create foo {constructor {a} {}}
>>> | >     ::foo
>>> | >     % set f [foo new]
>>> | >     ::oo::Obj12
>>> | >     % set f [foo new a b c]
>>> | >     ::oo::Obj13
>>> | >
>>> | > I'd expect both attempts to create objects to fail because neither
>>> | > specifies the correct number of arguments.
>>> | >
>>> | > Have I misunderstood something (if so, what) or is there a bug here?
>>>>
>>> | Looks like the constructor is not even created if the body is
>>> empty. As
>>> | soon as you put something in the body the arguments are checked:
>>>
>>> Even an comment is sufficient to trigger this:
>>>
>>>      % oo::class create foo {constructor {} {#;}}
>>>      ::foo
>>>      % set g [foo new a b c]
>>>      wrong # args: should be "foo new"
>>>
>>> But I would file "not checking the arguments" under 'bug' anyway...
>>>
>>> R'
>>
>> Thanks Joerg, Ralf. I didn't realise that the default constructor (if
>> none was specified) would accept an arbitrary number of arguments.
>>
>> I'll raise a bug report about the differing behaviour between a
>> constructor with and without a body.
>>
>> Alan
>
> I've raised ticket [7a0f53f4] in the core fossil repo - I hope that's
> the right place.
>
> In the course of reformulating the example, I discovered that a single
> space is sufficient to cause he arguments to be checked.
>
I've had a response to this ticket from Donal Fellows. He drew my
attention to the statement in the contructor section of the oo::define
manpage that reads "If bodyScript is the empty string, the constructor
will be deleted". This certainly explains the difference in behaviour
between

oo::class create foo {constructor {} {}}

and

oo::class create foo {constructor {} { }}

However, I wasn't expecting that if I fail to specify a constructor
explicitly when defining a class, then the default constructor accepts
any (or no) arguments. It strikes me that if you don't define a
constructor then you'd expect the default constructor to accept *no*
arguments and that if you later create an instance of the class passing
some arguments, then that creation is an error.

If enough people agree with me, I'll have a go at persuading Donal to
reopen the ticket and change the default constructor.

Subject: Re: Something odd with [oo::class create] on Tcl 8.6.13
From: Ralf Fassel
Newsgroups: comp.lang.tcl
Date: Wed, 29 May 2024 09:00 UTC
References: 1 2 3 4 5
Path: eternal-september.org!news.eternal-september.org!feeder3.eternal-september.org!fu-berlin.de!uni-berlin.de!individual.net!not-for-mail
From: ralfixx@gmx.de (Ralf Fassel)
Newsgroups: comp.lang.tcl
Subject: Re: Something odd with [oo::class create] on Tcl 8.6.13
Date: Wed, 29 May 2024 11:00:31 +0200
Lines: 37
Message-ID: <yga8qztro0g.fsf@akutech.de>
References: <usn9u8$3mlci$1@dont-email.me>
<87jzm8whs2.fsf@jmertens.eternal-september.org>
<ygav85ry9xs.fsf@panther.akutech-local.de>
<usuhd1$1hjpd$1@dont-email.me> <v35k78$pdgr$1@dont-email.me>
Mime-Version: 1.0
Content-Type: text/plain
X-Trace: individual.net uHP4pSRIb5JbcizRFcuL6wdUzD2EGFKN6QSDs6jM3TlTbdWEg=
Cancel-Lock: sha1:OYPNtZ3tsksKZHgqI5Bk8EC2wws= sha1:204PUeXv9Pxf5eWatctmxeZH1Yc= sha256:MnFwtW5OjLx94z8lwSYIxhmFGSSKEEg0ra4502s6nsM=
User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.2 (gnu/linux)
View all headers

* Alan Grunwald <nospam.nurdglaw@gmail.com>
| > On 14/03/2024 09:52, Alan Grunwald wrote:
| > I've raised ticket [7a0f53f4] in the core fossil repo - I hope
| > that's the right place.
| > In the course of reformulating the example, I discovered that a
| > single space is sufficient to cause he arguments to be checked.
| >
| I've had a response to this ticket from Donal Fellows. He drew my
| attention to the statement in the contructor section of the oo::define
| manpage that reads "If bodyScript is the empty string, the constructor
| will be deleted". This certainly explains the difference in behaviour
| between
>
| oo::class create foo {constructor {} {}}
>
| and
>
| oo::class create foo {constructor {} { }}
>
| However, I wasn't expecting that if I fail to specify a constructor
| explicitly when defining a class, then the default constructor accepts
| any (or no) arguments. It strikes me that if you don't define a
| constructor then you'd expect the default constructor to accept *no*
| arguments and that if you later create an instance of the class
| passing some arguments, then that creation is an error.

I'd second that. This is how c++ does it (there even the
wrong type of argument results in compilation error).

| If enough people agree with me, I'll have a go at persuading Donal to
| reopen the ticket and change the default constructor.

I would think that if I need a CTOR which accepts (and probably
discards) any number of arguments, then creating one accepting 'args'
would be the way to go.

R'

1

rocksolid light 0.9.8
clearnet tor