Rocksolid Light

Welcome to Rocksolid Light

mail  files  register  newsreader  groups  login

Message-ID:  

Never trust a computer you can't repair yourself.


devel / comp.lang.c++ / Re: Q: how to make an object that throws

SubjectAuthor
* Q: how to make an object that throwsRoss Finlayson
+* Re: Q: how to make an object that throwsSam
|`* Re: Q: how to make an object that throwsRoss Finlayson
| `* Re: Q: how to make an object that throwsSam
|  `* Re: Q: how to make an object that throwsRoss Finlayson
|   `* Re: Q: how to make an object that throwsSam
|    `* Re: Q: how to make an object that throwsRoss Finlayson
|     `- Re: Q: how to make an object that throwsRoss Finlayson
`* Re: Q: how to make an object that throwsZhengyi Fu
 +- Re: Q: how to make an object that throwsRoss Finlayson
 +* Re: Q: how to make an object that throwswij
 |`- Re: Q: how to make an object that throwsRoss Finlayson
 `* Re: Q: how to make an object that throwsStefan Ram
  +* Re: Q: how to make an object that throwsRoss Finlayson
  |`- Re: Q: how to make an object that throwsRoss Finlayson
  `- Re: Q: how to make an object that throwsTim Rentsch

1
Q: how to make an object that throws

<n6Ocnf_tkL8shbr7nZ2dnZfqn_qdnZ2d@giganews.com>

  copy mid

https://news.novabbs.org/devel/article-flat.php?id=3719&group=comp.lang.c%2B%2B#3719

  copy link   Newsgroups: comp.lang.c++
Path: i2pn2.org!i2pn.org!weretis.net!feeder6.news.weretis.net!border-1.nntp.ord.giganews.com!nntp.giganews.com!Xl.tags.giganews.com!local-1.nntp.ord.giganews.com!news.giganews.com.POSTED!not-for-mail
NNTP-Posting-Date: Tue, 23 Apr 2024 02:10:57 +0000
Newsgroups: comp.lang.c++
X-Mozilla-News-Host: snews://giganews.com:443
From: ross.a.finlayson@gmail.com (Ross Finlayson)
Subject: Q: how to make an object that throws
Date: Mon, 22 Apr 2024 19:11:13 -0700
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101
Thunderbird/38.6.0
MIME-Version: 1.0
Content-Type: text/plain; charset=utf-8; format=flowed
Content-Transfer-Encoding: 7bit
Message-ID: <n6Ocnf_tkL8shbr7nZ2dnZfqn_qdnZ2d@giganews.com>
Lines: 19
X-Usenet-Provider: http://www.giganews.com
X-Trace: sv3-WHIdAH191n8XgVKUiAboKGxIL4+f1IIhDAe1Wxc0c/aNrwTHuSYR1auRRMWqCr9qmtct8+QvMtgH8dW!9M6WisOipSPX9fX1Ub9SbAqLOVnqFzKryOAkYCjmoPm3TbqWQqQyszUG5E2/ryDjHXe4Sz/VpDU=
X-Complaints-To: abuse@giganews.com
X-DMCA-Notifications: http://www.giganews.com/info/dmca.html
X-Abuse-and-DMCA-Info: Please be sure to forward a copy of ALL headers
X-Abuse-and-DMCA-Info: Otherwise we will be unable to process your complaint properly
X-Postfilter: 1.3.40
 by: Ross Finlayson - Tue, 23 Apr 2024 02:11 UTC

Hello I hope I might consult your expertise, I'm wondering about
a use-case where for a given library object, to provide an instance
of same type, that on any access, throws an exception.

The idea is that there's an idea in a different language where
the runtime throws a null_pointer_dereference exception
when dereferencing a null pointer, yet in C++ it's signal segfault.

So, what I wonder about is how to make an object in C++,
of a given standard library type, and any arbitrary type,
that on any access, throws.

I suppose I might static_cast an object yet I wonder how
to make it so then that any access to it throws.

As you might imagine it's a use-case for exceptions
as part of flow-of-control, that in the other language
just is null yet in C++ would be for "an object of all types",
that throws on any access.

Re: Q: how to make an object that throws

<cone.1713839569.577249.2570.1004@monster.email-scan.com>

  copy mid

https://news.novabbs.org/devel/article-flat.php?id=3721&group=comp.lang.c%2B%2B#3721

  copy link   Newsgroups: comp.lang.c++
Path: i2pn2.org!i2pn.org!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: sam@email-scan.com (Sam)
Newsgroups: comp.lang.c++
Subject: Re: Q: how to make an object that throws
Date: Mon, 22 Apr 2024 22:32:49 -0400
Organization: A noiseless patient Spider
Lines: 8
Message-ID: <cone.1713839569.577249.2570.1004@monster.email-scan.com>
References: <n6Ocnf_tkL8shbr7nZ2dnZfqn_qdnZ2d@giganews.com>
MIME-Version: 1.0
Content-Type: text/plain; format=flowed; delsp=yes; charset="UTF-8"
Content-Transfer-Encoding: 7bit
Injection-Date: Tue, 23 Apr 2024 04:32:50 +0200 (CEST)
Injection-Info: dont-email.me; posting-host="b96f6b776b3bc0fc28b419148aeecda6";
logging-data="1480065"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18S4PPwY9hCpuQCNi3kHK78"
Cancel-Lock: sha1:blLhDFj98+JMVXdyOLmh6fggufE=
X-Mailer: https://www.courier-mta.org/cone/
X-Shameless-Plug: https://github.com/svarshavchik
Content-Disposition: inline
 by: Sam - Tue, 23 Apr 2024 02:32 UTC

Ross Finlayson writes:

> Hello I hope I might consult your expertise, I'm wondering about
> a use-case where for a given library object, to provide an instance
> of same type, that on any access, throws an exception.

What does "any access" mean? Please be specific.

Re: Q: how to make an object that throws

<87wmoon5d3.fsf@fuzy.me>

  copy mid

https://news.novabbs.org/devel/article-flat.php?id=3722&group=comp.lang.c%2B%2B#3722

  copy link   Newsgroups: comp.lang.c++
Path: i2pn2.org!i2pn.org!weretis.net!feeder6.news.weretis.net!border-3.nntp.ord.giganews.com!nntp.giganews.com!news-out.netnews.com!postmaster.netnews.com!us4.netnews.com!not-for-mail
X-Trace: DXC=F:Q4F<dUAP09XDEh4VolD0U5[F2hIijD?7J470dMQQ7;J4R`5ADBYn2l[<QJ]_Zei9bIg>KCJ8QO3e^k]2GCY;e<<j9Kk1IaW[9H>kd\a?<iU=S`I?D9:eV0?
X-Complaints-To: support@frugalusenet.com
From: i@fuzy.me (Zhengyi Fu)
Newsgroups: comp.lang.c++
Subject: Re: Q: how to make an object that throws
References: <n6Ocnf_tkL8shbr7nZ2dnZfqn_qdnZ2d@giganews.com>
Autocrypt: addr=i@fuzy.me; prefer-encrypt=mutual; keydata=
mDMEZd/p6xYJKwYBBAHaRw8BAQdAgfxm2J8gGxjf4AdWV2tbEeyvKgwJXzqM8YP+94TCVpC0Flpo
ZW5neWkgRnUgPGlAZnV6eS5tZT6IlAQTFgoAPBYhBKvlCzHi8MlKxFhbx42Xvz9r+gvaBQJl3+nr
AhsDBQkB4TOABAsJCAcEFQoJCAUWAgMBAAIeBQIXgAAKCRCNl78/a/oL2pUpAQCK73vpSpFmZCnW
8uSjF5oPX7o4vF0ZyE402niPCDgokAEAiQAd9Zatc3d1wut9k/hu35IWSRTGYrjpHAXxHQofhge4
OARl3+nrEgorBgEEAZdVAQUBAQdAEhCj39QK+6jFSqUC2BbRkdtqRk2mQ/Vsmc1LkCGhQWQDAQgH
iH4EGBYKACYWIQSr5Qsx4vDJSsRYW8eNl78/a/oL2gUCZd/p6wIbDAUJAeEzgAAKCRCNl78/a/oL
2nA4AQCHPVWH59hKZywHRETK0RGzM0EPoZXcAQgODXO+UTCZMgD9FH2WPMfr6qtWwfE6bTPbLr3m
c4e3XtgnBlhDyokwoAK4MwRl5Y0qFgkrBgEEAdpHDwEBB0A5XU/3jujthG0KBIaTJONjeJxyWYvB
V6bMEA17KBFYgIh+BBgWCAAmFiEEq+ULMeLwyUrEWFvHjZe/P2v6C9oFAmXljSoCGyAFCQDtTgAA
CgkQjZe/P2v6C9qvpQD+MhFoxnZUUsFTNJWQhDcgtsXtTza89Wifd1Eshl5M1FYA/jqNr4FXv4b7
GVC3MYKbwKPqS0OElnfn/kCHWK2BIH0O
Date: Tue, 23 Apr 2024 11:08:08 +0800
Message-ID: <87wmoon5d3.fsf@fuzy.me>
User-Agent: Gnus/5.13 (Gnus v5.13)
Cancel-Lock: sha1:8eZyPjvn5eB+QuKgFabwtazKqzc=
MIME-Version: 1.0
Content-Type: text/plain
Lines: 77
NNTP-Posting-Host: 127.0.0.1
X-Trace: 1713841689 reader.netnews.com 7169 127.0.0.1:45483
 by: Zhengyi Fu - Tue, 23 Apr 2024 03:08 UTC

Ross Finlayson <ross.a.finlayson@gmail.com> writes:

> Hello I hope I might consult your expertise, I'm wondering about
> a use-case where for a given library object, to provide an instance
> of same type, that on any access, throws an exception.
>
> The idea is that there's an idea in a different language where
> the runtime throws a null_pointer_dereference exception
> when dereferencing a null pointer, yet in C++ it's signal segfault.
>
> So, what I wonder about is how to make an object in C++,
> of a given standard library type, and any arbitrary type,
> that on any access, throws.
>
> I suppose I might static_cast an object yet I wonder how
> to make it so then that any access to it throws.
>
> As you might imagine it's a use-case for exceptions
> as part of flow-of-control, that in the other language
> just is null yet in C++ would be for "an object of all types",
> that throws on any access.
>

I believe there is no portable way to implement this.

However, if you are running GCC on supported platforms, you can try
the `-fnon-call-exceptions` option.

--8<---------------cut here---------------start------------->8---
// main.cpp
#include <sys/types.h>
#include <signal.h>
#include <iostream>
#include <exception>

extern "C" void handle_signal(int signum) {
throw std::runtime_error("Invalid access");
}

int main()
{ struct sigaction act;
act.sa_handler = &handle_signal;
sigemptyset(&act.sa_mask);
act.sa_flags = SA_NODEFER;
sigaction(SIGSEGV, &act, nullptr);

int *object = NULL;

try {
// write
*object = 100;
} catch (std::exception& exc) {
std::cerr << "Caught exception: " << exc.what() << '\n';
}

try {
// read
int value = *object;
std::cout << "value = " << value << '\n';
} catch (std::exception& exc) {
std::cerr << "Caught exception: " << exc.what() << '\n';
}
} --8<---------------cut here---------------end--------------->8---

Compile the source file with

g++ -fnon-call-exceptions -o test main.cpp

Run ./test, it outputs

Caught exception: Invalid access
Caught exception: Invalid access

--
Zhengyi Fu

Re: Q: how to make an object that throws

<ZIKdnZ34YN_Wo7r7nZ2dnZfqnPqdnZ2d@giganews.com>

  copy mid

https://news.novabbs.org/devel/article-flat.php?id=3724&group=comp.lang.c%2B%2B#3724

  copy link   Newsgroups: comp.lang.c++
Path: i2pn2.org!i2pn.org!weretis.net!feeder6.news.weretis.net!border-2.nntp.ord.giganews.com!nntp.giganews.com!Xl.tags.giganews.com!local-2.nntp.ord.giganews.com!news.giganews.com.POSTED!not-for-mail
NNTP-Posting-Date: Tue, 23 Apr 2024 04:51:23 +0000
Subject: Re: Q: how to make an object that throws
Newsgroups: comp.lang.c++
References: <n6Ocnf_tkL8shbr7nZ2dnZfqn_qdnZ2d@giganews.com>
<cone.1713839569.577249.2570.1004@monster.email-scan.com>
From: ross.a.finlayson@gmail.com (Ross Finlayson)
Date: Mon, 22 Apr 2024 21:51:42 -0700
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101
Thunderbird/38.6.0
MIME-Version: 1.0
In-Reply-To: <cone.1713839569.577249.2570.1004@monster.email-scan.com>
Content-Type: text/plain; charset=utf-8; format=flowed
Content-Transfer-Encoding: 7bit
Message-ID: <ZIKdnZ34YN_Wo7r7nZ2dnZfqnPqdnZ2d@giganews.com>
Lines: 112
X-Usenet-Provider: http://www.giganews.com
X-Trace: sv3-bnhU/LwFg55O8MzSZDxqgYGBpYAaPDNfPTF0ZSQaKTapCzmllHIBTNuF/whsBD7qa/6KKUNPk0eOJVn!jSmn3we2gbfOJJykqudKIqjG5/jFmaU53RGF6uGdzz5Iim1FrlBrcRfOWERwA1wJvYXQiFmxkTU=
X-Complaints-To: abuse@giganews.com
X-DMCA-Notifications: http://www.giganews.com/info/dmca.html
X-Abuse-and-DMCA-Info: Please be sure to forward a copy of ALL headers
X-Abuse-and-DMCA-Info: Otherwise we will be unable to process your complaint properly
X-Postfilter: 1.3.40
 by: Ross Finlayson - Tue, 23 Apr 2024 04:51 UTC

On 04/22/2024 07:32 PM, Sam wrote:
> Ross Finlayson writes:
>
>> Hello I hope I might consult your expertise, I'm wondering about
>> a use-case where for a given library object, to provide an instance
>> of same type, that on any access, throws an exception.
>
> What does "any access" mean? Please be specific.
>

As if it were null, whatever would raise a segfault,
is the idea of "any access", then I wish I better
explain the differences among pointers, references, and
class returns from functions, looking at C++ 11,
and trying to understand some of the newer syntactic
sugar with regards to declarations.

std::vector<int> values() {
return static_cast<std::vector<int>> nullptr; // no
}

The idea is that some code can compute partial results,
or to the effect of launching asynchronous requests

void rr1(const std::string& s) {

std::list<std::string> l1 = rr2(s);

int i1 = rr3(s);
int i2 = rr4(s);

int siz = l1.size(); // throw

int i3 = rr5(i1, i2, l1.size());

}

so the idea is the re-routine runs through statements
as long as the inputs are satisfied, then these
rr1, 2, 3, 4, 5 throw if their arguments are the
null_throwing type, and any library code access
on the null_throwing type also throws.

Then the idea is that as a task, rr1 gets invoked,
that basically it's a future

std::future<int> rr1(const std::string& s) {

std::future<std::list<std::string>> l1 = rr2(s);

std::future<int> i1 = rr3(s);
std::future<int> i2 = rr4(s);

int siz = l1.size(); // throw

std::future<int> i3 = rr5(i1, i2, l1.size());

}

that the "re-routine" throws while its side affect
is that it launches (initiates) the asynchronous
call, that the callback (completion) populates a
partial results for the task that invokes this,
and adds another task to invoke the same re-routine
with the same arguments, which sets thread-local
(thread_local storage) in the task caller, the
retried asynchronous results, then rr the re-routine
is run over and over until it completes, using
exceptions as flow-of-control for "quit until satisfied".

It's an idea for writing co-routines in the language
as synchronous the routine, so what I'm hoping is to
figure out how to write routines as if they were
synchronous and blocking, what make for some convention
that as re-routines they can be implemented with
asynchronous callbacks, that the task queue, sets
them up with a "monad" a memoization as it goes along.

Then what I hope is to make something like nullptr
that can be cast to result an rvalue for any lvalue,
that on access dereference as a nullptr, would throw.

This way then the re-routine sort of automatically
primes its asynchronous results in whatever results
getting to the invoked re-routines, "satisfied" or
"satisfying" inputs, so that they're initiated
with completion handlers to populate the monad
and push the next re-run or the re-routine to
the task queue, which flows in the otherwise
flow-of-control in the language exactly the same
each time until it itself actually completes
and calls back to the originating (initiating)
callback (completion handler).

It's an idea to write asynchronous code as
the same as blocking code then run cooperative
multithreading as re-routines that never block
(yet may throw).

(It's been a while, I need to learn C++ 11
and even parts of C++ 03 and figure to target
C++ 11 for this kind of idea. There's that
std::future appears to be sub-classable and
will throw a future_error yet I'd hope that
what happens is that the resulting lvalue
just sits until it's accessed or as if
treated as a null pointer like nullptr,
then throws a given 'flow-of-control' exception.)

Re: Q: how to make an object that throws

<ZIKdnZz4YN8Po7r7nZ2dnZfqnPoAAAAA@giganews.com>

  copy mid

https://news.novabbs.org/devel/article-flat.php?id=3725&group=comp.lang.c%2B%2B#3725

  copy link   Newsgroups: comp.lang.c++
Path: i2pn2.org!i2pn.org!weretis.net!feeder6.news.weretis.net!border-2.nntp.ord.giganews.com!border-4.nntp.ord.giganews.com!nntp.giganews.com!Xl.tags.giganews.com!local-1.nntp.ord.giganews.com!news.giganews.com.POSTED!not-for-mail
NNTP-Posting-Date: Tue, 23 Apr 2024 04:52:34 +0000
Subject: Re: Q: how to make an object that throws
Newsgroups: comp.lang.c++
References: <n6Ocnf_tkL8shbr7nZ2dnZfqn_qdnZ2d@giganews.com>
<87wmoon5d3.fsf@fuzy.me>
From: ross.a.finlayson@gmail.com (Ross Finlayson)
Date: Mon, 22 Apr 2024 21:52:54 -0700
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101
Thunderbird/38.6.0
MIME-Version: 1.0
In-Reply-To: <87wmoon5d3.fsf@fuzy.me>
Content-Type: text/plain; charset=windows-1252; format=flowed
Content-Transfer-Encoding: 7bit
Message-ID: <ZIKdnZz4YN8Po7r7nZ2dnZfqnPoAAAAA@giganews.com>
Lines: 81
X-Usenet-Provider: http://www.giganews.com
X-Trace: sv3-O6RI6a2A4WPvIO5p1nQHrcP1okoCPfnABhIwAIi/wxdZtaGE8HkmTKMfK7Mguzwx1+Mx2OGy1XfAIvz!RI95ujsJaujMSvzVnt/P3BjM7NhZXhrSCqBSkACLeBiWgPF5isfqGYoMJloqNORnkw/xxR2fVtU=
X-Complaints-To: abuse@giganews.com
X-DMCA-Notifications: http://www.giganews.com/info/dmca.html
X-Abuse-and-DMCA-Info: Please be sure to forward a copy of ALL headers
X-Abuse-and-DMCA-Info: Otherwise we will be unable to process your complaint properly
X-Postfilter: 1.3.40
 by: Ross Finlayson - Tue, 23 Apr 2024 04:52 UTC

On 04/22/2024 08:08 PM, Zhengyi Fu wrote:
> Ross Finlayson <ross.a.finlayson@gmail.com> writes:
>
>> Hello I hope I might consult your expertise, I'm wondering about
>> a use-case where for a given library object, to provide an instance
>> of same type, that on any access, throws an exception.
>>
>> The idea is that there's an idea in a different language where
>> the runtime throws a null_pointer_dereference exception
>> when dereferencing a null pointer, yet in C++ it's signal segfault.
>>
>> So, what I wonder about is how to make an object in C++,
>> of a given standard library type, and any arbitrary type,
>> that on any access, throws.
>>
>> I suppose I might static_cast an object yet I wonder how
>> to make it so then that any access to it throws.
>>
>> As you might imagine it's a use-case for exceptions
>> as part of flow-of-control, that in the other language
>> just is null yet in C++ would be for "an object of all types",
>> that throws on any access.
>>
>
> I believe there is no portable way to implement this.
>
> However, if you are running GCC on supported platforms, you can try
> the `-fnon-call-exceptions` option.
>
> --8<---------------cut here---------------start------------->8---
> // main.cpp
> #include <sys/types.h>
> #include <signal.h>
> #include <iostream>
> #include <exception>
>
> extern "C" void handle_signal(int signum) {
> throw std::runtime_error("Invalid access");
> }
>
> int main()
> {
> struct sigaction act;
> act.sa_handler = &handle_signal;
> sigemptyset(&act.sa_mask);
> act.sa_flags = SA_NODEFER;
> sigaction(SIGSEGV, &act, nullptr);
>
> int *object = NULL;
>
> try {
> // write
> *object = 100;
> } catch (std::exception& exc) {
> std::cerr << "Caught exception: " << exc.what() << '\n';
> }
>
> try {
> // read
> int value = *object;
> std::cout << "value = " << value << '\n';
> } catch (std::exception& exc) {
> std::cerr << "Caught exception: " << exc.what() << '\n';
> }
> }
> --8<---------------cut here---------------end--------------->8---
>
> Compile the source file with
>
> g++ -fnon-call-exceptions -o test main.cpp
>
> Run ./test, it outputs
>
> Caught exception: Invalid access
> Caught exception: Invalid access
>

Hey, that's great. Hey, thanks, that's kind
of good to know.

Re: Q: how to make an object that throws

<cone.1713871619.641020.31152.1004@monster.email-scan.com>

  copy mid

https://news.novabbs.org/devel/article-flat.php?id=3727&group=comp.lang.c%2B%2B#3727

  copy link   Newsgroups: comp.lang.c++
Path: i2pn2.org!i2pn.org!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: sam@email-scan.com (Sam)
Newsgroups: comp.lang.c++
Subject: Re: Q: how to make an object that throws
Date: Tue, 23 Apr 2024 07:26:59 -0400
Organization: A noiseless patient Spider
Lines: 111
Message-ID: <cone.1713871619.641020.31152.1004@monster.email-scan.com>
References: <n6Ocnf_tkL8shbr7nZ2dnZfqn_qdnZ2d@giganews.com> <cone.1713839569.577249.2570.1004@monster.email-scan.com> <ZIKdnZ34YN_Wo7r7nZ2dnZfqnPqdnZ2d@giganews.com>
MIME-Version: 1.0
Content-Type: text/plain; format=flowed; delsp=yes; charset="UTF-8"
Content-Transfer-Encoding: 7bit
Injection-Date: Tue, 23 Apr 2024 13:27:02 +0200 (CEST)
Injection-Info: dont-email.me; posting-host="b96f6b776b3bc0fc28b419148aeecda6";
logging-data="1686389"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+9Bx59qr99gcsOsSy4U/n/"
Cancel-Lock: sha1:uO9nQ1C+bKKcTQI+AQTLEJfLVNE=
Content-Disposition: inline
X-Shameless-Plug: https://github.com/svarshavchik
X-Mailer: https://www.courier-mta.org/cone/
 by: Sam - Tue, 23 Apr 2024 11:26 UTC

Ross Finlayson writes:

> On 04/22/2024 07:32 PM, Sam wrote:
>> Ross Finlayson writes:
>>
>>> Hello I hope I might consult your expertise, I'm wondering about
>>> a use-case where for a given library object, to provide an instance
>>> of same type, that on any access, throws an exception.
>>
>> What does "any access" mean? Please be specific.
>>
>
> As if it were null, whatever would raise a segfault,
> is the idea of "any access", then I wish I better

Again, you need to explain what "whatever" means.

Are you looking for a class with deleted copy/move constructors or
assignment operators?

Are you looking for a class with an overloaded * or -> operator that throws
an exception?

/What/ are you looking for?

> explain the differences among pointers, references, and
> class returns from functions, looking at C++ 11,
> and trying to understand some of the newer syntactic
> sugar with regards to declarations.

Perhaps it would be more productive to invest a little bit more time
studying C++11, and learning the different parts of C++, what they are, and
how they work, before attempting to ask a meaningful question.

The term "any access" is utterly meaningless and context-free, in C++ terms.
Nobody really understands what exactly you're asking.

>
>
> std::vector<int> values() {
> return static_cast<std::vector<int>> nullptr; // no
> }

No self-respecting C++ compiler will compile this. This is syntactically
invalid.

> The idea is that some code can compute partial results,
> or to the effect of launching asynchronous requests
>
> void rr1(const std::string& s) {
>
> std::list<std::string> l1 = rr2(s);
>
> int i1 = rr3(s);
> int i2 = rr4(s);
>
> int siz = l1.size(); // throw
>
> int i3 = rr5(i1, i2, l1.size());
>
> }

What is "rr2"? What is "rr3"? What is "rr4"? What is "rr5"?

> so the idea is the re-routine runs through statements
> as long as the inputs are satisfied, then these

What "inputs"? What does "satisfied" mean?

> rr1, 2, 3, 4, 5 throw if their arguments are the
> null_throwing type, and any library code access

What does "null_throwing" mean?

C++ is very complicated. When discussing C++ it is very important to be
explicit and use consistent terms that are well-defined in C++.

[deletia]

> It's an idea for writing co-routines in the language

You will do yourself a huge, huge favor, by forgetting everything about co-
routines.

co-routines are a solution in search of a problem.

The only reason co-routines exist in C++ is because real execution threads
absolutely suck raw eggs in Microsoft Windows, and Microsoft hijacked the
standardization process to infect C++ with this co-routines bullshit just so
that MS-Windows would finally have a multi-threading implementation model
that does not suck.

> This way then the re-routine sort of automatically
> primes its asynchronous results in whatever results
> getting to the invoked re-routines, "satisfied" or
> "satisfying" inputs, so that they're initiated
> with completion handlers to populate the monad
> and push the next re-run or the re-routine to
> the task queue, which flows in the otherwise
> flow-of-control in the language exactly the same
> each time until it itself actually completes
> and calls back to the originating (initiating)
> callback (completion handler).

Go ask Microsoft. They invented all this bullshit. They can deal with it,
by themselves.

> (It's been a while, I need to learn C++ 11

co-routines are not C++11.

Re: Q: how to make an object that throws

<WbOcnbgzN9y9S7r7nZ2dnZfqn_udnZ2d@giganews.com>

  copy mid

https://news.novabbs.org/devel/article-flat.php?id=3735&group=comp.lang.c%2B%2B#3735

  copy link   Newsgroups: comp.lang.c++
Path: i2pn2.org!i2pn.org!weretis.net!feeder6.news.weretis.net!border-4.nntp.ord.giganews.com!border-2.nntp.ord.giganews.com!border-1.nntp.ord.giganews.com!nntp.giganews.com!Xl.tags.giganews.com!local-1.nntp.ord.giganews.com!news.giganews.com.POSTED!not-for-mail
NNTP-Posting-Date: Tue, 23 Apr 2024 15:39:11 +0000
Subject: Re: Q: how to make an object that throws
Newsgroups: comp.lang.c++
References: <n6Ocnf_tkL8shbr7nZ2dnZfqn_qdnZ2d@giganews.com>
<cone.1713839569.577249.2570.1004@monster.email-scan.com>
<ZIKdnZ34YN_Wo7r7nZ2dnZfqnPqdnZ2d@giganews.com>
<cone.1713871619.641020.31152.1004@monster.email-scan.com>
From: ross.a.finlayson@gmail.com (Ross Finlayson)
Date: Tue, 23 Apr 2024 08:39:11 -0700
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101
Thunderbird/38.6.0
MIME-Version: 1.0
In-Reply-To: <cone.1713871619.641020.31152.1004@monster.email-scan.com>
Content-Type: text/plain; charset=utf-8; format=flowed
Content-Transfer-Encoding: 7bit
Message-ID: <WbOcnbgzN9y9S7r7nZ2dnZfqn_udnZ2d@giganews.com>
Lines: 161
X-Usenet-Provider: http://www.giganews.com
X-Trace: sv3-dsIimim7LnmqPDsETJDKGjNYWv/yBsVcKkO2YG0+WfXoJCyaQ+eIs4ePl3//XXPLut1Q86A4EchtLLg!w1jpfCTd78HDo2SpEsppKaBYkkGi/JGPIfc9UGKJuY6JQQYSIDfn60V0bzt2oQM8ohysIOl3FkY=
X-Complaints-To: abuse@giganews.com
X-DMCA-Notifications: http://www.giganews.com/info/dmca.html
X-Abuse-and-DMCA-Info: Please be sure to forward a copy of ALL headers
X-Abuse-and-DMCA-Info: Otherwise we will be unable to process your complaint properly
X-Postfilter: 1.3.40
 by: Ross Finlayson - Tue, 23 Apr 2024 15:39 UTC

On 04/23/2024 04:26 AM, Sam wrote:
> Ross Finlayson writes:
>
>> On 04/22/2024 07:32 PM, Sam wrote:
>>> Ross Finlayson writes:
>>>
>>>> Hello I hope I might consult your expertise, I'm wondering about
>>>> a use-case where for a given library object, to provide an instance
>>>> of same type, that on any access, throws an exception.
>>>
>>> What does "any access" mean? Please be specific.
>>>
>>
>> As if it were null, whatever would raise a segfault,
>> is the idea of "any access", then I wish I better
>
> Again, you need to explain what "whatever" means.
>
> Are you looking for a class with deleted copy/move constructors or
> assignment operators?
>
> Are you looking for a class with an overloaded * or -> operator that
> throws an exception?
>
> /What/ are you looking for?
>
>> explain the differences among pointers, references, and
>> class returns from functions, looking at C++ 11,
>> and trying to understand some of the newer syntactic
>> sugar with regards to declarations.
>
> Perhaps it would be more productive to invest a little bit more time
> studying C++11, and learning the different parts of C++, what they are,
> and how they work, before attempting to ask a meaningful question.
>
> The term "any access" is utterly meaningless and context-free, in C++
> terms. Nobody really understands what exactly you're asking.
>
>>
>>
>> std::vector<int> values() {
>> return static_cast<std::vector<int>> nullptr; // no
>> }
>
> No self-respecting C++ compiler will compile this. This is syntactically
> invalid.
>
>> The idea is that some code can compute partial results,
>> or to the effect of launching asynchronous requests
>>
>> void rr1(const std::string& s) {
>>
>> std::list<std::string> l1 = rr2(s);
>>
>> int i1 = rr3(s);
>> int i2 = rr4(s);
>>
>> int siz = l1.size(); // throw
>>
>> int i3 = rr5(i1, i2, l1.size());
>>
>> }
>
> What is "rr2"? What is "rr3"? What is "rr4"? What is "rr5"?
>
>> so the idea is the re-routine runs through statements
>> as long as the inputs are satisfied, then these
>
> What "inputs"? What does "satisfied" mean?
>
>> rr1, 2, 3, 4, 5 throw if their arguments are the
>> null_throwing type, and any library code access
>
> What does "null_throwing" mean?
>
> C++ is very complicated. When discussing C++ it is very important to be
> explicit and use consistent terms that are well-defined in C++.
>
> [deletia]
>
>> It's an idea for writing co-routines in the language
>
> You will do yourself a huge, huge favor, by forgetting everything about
> co-routines.
>
> co-routines are a solution in search of a problem.
>
> The only reason co-routines exist in C++ is because real execution
> threads absolutely suck raw eggs in Microsoft Windows, and Microsoft
> hijacked the standardization process to infect C++ with this co-routines
> bullshit just so that MS-Windows would finally have a multi-threading
> implementation model that does not suck.
>
>> This way then the re-routine sort of automatically
>> primes its asynchronous results in whatever results
>> getting to the invoked re-routines, "satisfied" or
>> "satisfying" inputs, so that they're initiated
>> with completion handlers to populate the monad
>> and push the next re-run or the re-routine to
>> the task queue, which flows in the otherwise
>> flow-of-control in the language exactly the same
>> each time until it itself actually completes
>> and calls back to the originating (initiating)
>> callback (completion handler).
>
> Go ask Microsoft. They invented all this bullshit. They can deal with
> it, by themselves.
>
>> (It's been a while, I need to learn C++ 11
>
> co-routines are not C++11.
>

Hey Sam, thanks for writing.

The, "re-routines", are not, "co-routines". They're a model
of cooperative multithreading, which sort of by definition
are a co-routine yet not a co-routine in the runtime with
language support, semantics of defined behavior.

Instead it's an approach to callbacks, and a monadic approach,
with the idea that the originator/initiator of the overall
asynchronous re-routine, actually expects the invocations of
the tasks to fail (to "quit"), with the side-effect that their
asynchronous dependencies (the results, the values of the callbacks)
are initiated, what on their becoming available, also add the
task of the re-routine back to the originator/initiator/executor
of the re-routine, that the invocation of the task after its
dependencies, the arguments are fulfilled and satisfying, for
each of the sub-routines also re-routines, or any library code,
then it gets all done as a model of cooperative multithreading,
while the routine is written with no syntax of the asynchronous
at all, and can be implemented either blocking as a routine or
non-blocking as a re-routine, with the same code of the routine.

The idea is that this sort of approach to cooperative multithreading
needs thread_local storage specifier, and, basically aspects to
instrument the routine with its semantics of memoizing its results
in the partial monad of the sub-routines' results in the re-launches,
that the re-routine invokes all its asynchronous dependencies going
along, those returning their memoized results if available else
these null-throwing placeholders while launching themselves,
that it results non-blocking routines in re-routines,
with nothing at all about the semantics of asynchrony or callback,
because in the aspect its implicit, in the language,
in the defined behavior of the language and runtime.

So, right, it's not runtime or library coroutines or in the language
anything at all with the semantics of asynchrony, the idea is
re-routines that can be sort of implemented in regards to there
being virtual functions for these aspects, and thread_local storage,
and threads, for a pattern (anti-pattern) of non-blocking re-routines.

So, I suppose that would require C++ 11 for threads and thread_local,
while, otherwise it would be a usual simple sort of portability layer.

(Or as with regards to some conventions about ifdef and ifndef in
the language of m4 with regards to "portability", from basically
that writing network code for POSIX and Windows involves one.)

Re: Q: how to make an object that throws

<cone.1713924500.272635.96311.1004@monster.email-scan.com>

  copy mid

https://news.novabbs.org/devel/article-flat.php?id=3741&group=comp.lang.c%2B%2B#3741

  copy link   Newsgroups: comp.lang.c++
Path: i2pn2.org!i2pn.org!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: sam@email-scan.com (Sam)
Newsgroups: comp.lang.c++
Subject: Re: Q: how to make an object that throws
Date: Tue, 23 Apr 2024 22:08:20 -0400
Organization: A noiseless patient Spider
Lines: 28
Message-ID: <cone.1713924500.272635.96311.1004@monster.email-scan.com>
References: <n6Ocnf_tkL8shbr7nZ2dnZfqn_qdnZ2d@giganews.com> <cone.1713839569.577249.2570.1004@monster.email-scan.com> <ZIKdnZ34YN_Wo7r7nZ2dnZfqnPqdnZ2d@giganews.com> <cone.1713871619.641020.31152.1004@monster.email-scan.com> <WbOcnbgzN9y9S7r7nZ2dnZfqn_udnZ2d@giganews.com>
MIME-Version: 1.0
Content-Type: text/plain; format=flowed; delsp=yes; charset="UTF-8"
Content-Transfer-Encoding: 7bit
Injection-Date: Wed, 24 Apr 2024 04:08:22 +0200 (CEST)
Injection-Info: dont-email.me; posting-host="bcf1a80c4765627db986990781b1fa69";
logging-data="2192525"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18zPwtXpPBulGpB45h5ZVka"
Cancel-Lock: sha1:t4dtqWO0owOX+xH/Abz9eCQjkhw=
X-Shameless-Plug: https://github.com/svarshavchik
X-Mailer: https://www.courier-mta.org/cone/
Content-Disposition: inline
 by: Sam - Wed, 24 Apr 2024 02:08 UTC

Ross Finlayson writes:

> The idea is that this sort of approach to cooperative multithreading
> needs thread_local storage specifier, and, basically aspects to
> instrument the routine with its semantics of memoizing its results
> in the partial monad of the sub-routines' results in the re-launches,
> that the re-routine invokes all its asynchronous dependencies going
> along, those returning their memoized results if available else
> these null-throwing placeholders while launching themselves,
> that it results non-blocking routines in re-routines,
> with nothing at all about the semantics of asynchrony or callback,
> because in the aspect its implicit, in the language,
> in the defined behavior of the language and runtime.
>
> So, right, it's not runtime or library coroutines or in the language
> anything at all with the semantics of asynchrony, the idea is
> re-routines that can be sort of implemented in regards to there
> being virtual functions for these aspects, and thread_local storage,
> and threads, for a pattern (anti-pattern) of non-blocking re-routines.
>
> So, I suppose that would require C++ 11 for threads and thread_local,
> while, otherwise it would be a usual simple sort of portability layer.

That's a little bit above my pay grade. I am focused on the narrow question
of "how to make an object that throws", upon "access". I'm very confident
that there is a C++ answer to this question, as soon as "access" gets
defined concisely, using C++ terms and terminology.

Re: Q: how to make an object that throws

<QMmcnc7jD_z76rX7nZ2dnZfqn_ednZ2d@giganews.com>

  copy mid

https://news.novabbs.org/devel/article-flat.php?id=3742&group=comp.lang.c%2B%2B#3742

  copy link   Newsgroups: comp.lang.c++
Path: i2pn2.org!i2pn.org!weretis.net!feeder6.news.weretis.net!border-3.nntp.ord.giganews.com!border-4.nntp.ord.giganews.com!border-1.nntp.ord.giganews.com!nntp.giganews.com!Xl.tags.giganews.com!local-2.nntp.ord.giganews.com!news.giganews.com.POSTED!not-for-mail
NNTP-Posting-Date: Wed, 24 Apr 2024 03:07:18 +0000
Subject: Re: Q: how to make an object that throws
Newsgroups: comp.lang.c++
References: <n6Ocnf_tkL8shbr7nZ2dnZfqn_qdnZ2d@giganews.com>
<cone.1713839569.577249.2570.1004@monster.email-scan.com>
<ZIKdnZ34YN_Wo7r7nZ2dnZfqnPqdnZ2d@giganews.com>
<cone.1713871619.641020.31152.1004@monster.email-scan.com>
<WbOcnbgzN9y9S7r7nZ2dnZfqn_udnZ2d@giganews.com>
<cone.1713924500.272635.96311.1004@monster.email-scan.com>
From: ross.a.finlayson@gmail.com (Ross Finlayson)
Date: Tue, 23 Apr 2024 20:07:22 -0700
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101
Thunderbird/38.6.0
MIME-Version: 1.0
In-Reply-To: <cone.1713924500.272635.96311.1004@monster.email-scan.com>
Content-Type: text/plain; charset=utf-8; format=flowed
Content-Transfer-Encoding: 7bit
Message-ID: <QMmcnc7jD_z76rX7nZ2dnZfqn_ednZ2d@giganews.com>
Lines: 76
X-Usenet-Provider: http://www.giganews.com
X-Trace: sv3-AQHNE3Qt0FuzgWuvTxhJiGjwruED5ejkyk/rs3FwTnq3YwWJWwL8SHwKwxUv/uLeaGUQLnGK+mo4vFP!2we0D0ojZhZcIysiEiwlsOku1D7XeBot/bnEZE8a41L4foh8gFCRFWg085zsfjwvB4NPVTTtndR+
X-Complaints-To: abuse@giganews.com
X-DMCA-Notifications: http://www.giganews.com/info/dmca.html
X-Abuse-and-DMCA-Info: Please be sure to forward a copy of ALL headers
X-Abuse-and-DMCA-Info: Otherwise we will be unable to process your complaint properly
X-Postfilter: 1.3.40
 by: Ross Finlayson - Wed, 24 Apr 2024 03:07 UTC

On 04/23/2024 07:08 PM, Sam wrote:
> Ross Finlayson writes:
>
>> The idea is that this sort of approach to cooperative multithreading
>> needs thread_local storage specifier, and, basically aspects to
>> instrument the routine with its semantics of memoizing its results
>> in the partial monad of the sub-routines' results in the re-launches,
>> that the re-routine invokes all its asynchronous dependencies going
>> along, those returning their memoized results if available else
>> these null-throwing placeholders while launching themselves,
>> that it results non-blocking routines in re-routines,
>> with nothing at all about the semantics of asynchrony or callback,
>> because in the aspect its implicit, in the language,
>> in the defined behavior of the language and runtime.
>>
>> So, right, it's not runtime or library coroutines or in the language
>> anything at all with the semantics of asynchrony, the idea is
>> re-routines that can be sort of implemented in regards to there
>> being virtual functions for these aspects, and thread_local storage,
>> and threads, for a pattern (anti-pattern) of non-blocking re-routines.
>>
>> So, I suppose that would require C++ 11 for threads and thread_local,
>> while, otherwise it would be a usual simple sort of portability layer.
>
> That's a little bit above my pay grade. I am focused on the narrow
> question of "how to make an object that throws", upon "access". I'm very
> confident that there is a C++ answer to this question, as soon as
> "access" gets defined concisely, using C++ terms and terminology.
>

Zhengyi Fu pointed out that gcc has an option that for non-deferred
signals that are trapped that they can be made to throw a std::exception
in a non-portable manner, while, gcc is very widely implemented so it's
pretty portable, -fnon-call-exceptions.

Then, there's a notion that on Windows, there's ye olde Structured
Exception Handling, which it is said can catch what would be segfault in
the way that it is that it somehow employs setjmp/longjmp or rather
as how SEH works, to make it so that dereferencing null would
throw an exception instead of raising segfault.

(Dereferencing/dereference-ing.)

I would just hope to wonder and know that stack-unwinding or
the usual defined behavior or throwing a std::exception or
the behavior of throw was alright this way. What it seems
is the signal handler just has synthesized a throw right there,
as with regards to a bit of stack-magic where of course,
"there is no magic, there is only logic", then that SEH
accomplishes a same sort of thing. (Not sure how to
have SEH handler throw a std::exception.)

So, maybe there's, "a way", here still looking for,
"a way, defined in the language".

Hey thanks bud, I also am not quite sure otherwise how to go
about "making an object, assignable to any lvalue according
to a cast to its type, that when accessed, throws,
unwinding the stack in normal defined behavior".

It's appreciated that you are welcome to reject errancy, so, thanks.
I would rather be told wrong than wrongly think right.

So, we are still looking for a right sort of way, to
make an object, as an rvalue assignable to any lvalue,
that when "accessed", meaning any interaction at all
that doesn't just treat it like an assignment, and thinking
that assignment is only pointer or value assignment:
that it throws.

(Rather than causing a hardware fault and patching up
that it's alright.)

Re: Q: how to make an object that throws

<oiidnX7J2LfLCbX7nZ2dnZfqnPednZ2d@giganews.com>

  copy mid

https://news.novabbs.org/devel/article-flat.php?id=3743&group=comp.lang.c%2B%2B#3743

  copy link   Newsgroups: comp.lang.c++
Path: i2pn2.org!i2pn.org!weretis.net!feeder6.news.weretis.net!border-3.nntp.ord.giganews.com!border-1.nntp.ord.giganews.com!nntp.giganews.com!Xl.tags.giganews.com!local-2.nntp.ord.giganews.com!news.giganews.com.POSTED!not-for-mail
NNTP-Posting-Date: Wed, 24 Apr 2024 05:10:45 +0000
Subject: Re: Q: how to make an object that throws
Newsgroups: comp.lang.c++
References: <n6Ocnf_tkL8shbr7nZ2dnZfqn_qdnZ2d@giganews.com>
<cone.1713839569.577249.2570.1004@monster.email-scan.com>
<ZIKdnZ34YN_Wo7r7nZ2dnZfqnPqdnZ2d@giganews.com>
<cone.1713871619.641020.31152.1004@monster.email-scan.com>
<WbOcnbgzN9y9S7r7nZ2dnZfqn_udnZ2d@giganews.com>
<cone.1713924500.272635.96311.1004@monster.email-scan.com>
<QMmcnc7jD_z76rX7nZ2dnZfqn_ednZ2d@giganews.com>
From: ross.a.finlayson@gmail.com (Ross Finlayson)
Date: Tue, 23 Apr 2024 22:10:44 -0700
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101
Thunderbird/38.6.0
MIME-Version: 1.0
In-Reply-To: <QMmcnc7jD_z76rX7nZ2dnZfqn_ednZ2d@giganews.com>
Content-Type: text/plain; charset=utf-8; format=flowed
Content-Transfer-Encoding: 7bit
Message-ID: <oiidnX7J2LfLCbX7nZ2dnZfqnPednZ2d@giganews.com>
Lines: 202
X-Usenet-Provider: http://www.giganews.com
X-Trace: sv3-F9wpSSRTslXbucVdIrl+VwHx9BzrYN//Fk7byU4n9R2gFg4NTHCAQ9TscXvCf97QRPQ6Dav8FT3xq6A!eDE7jZ5eR/YeQRGNkWIVZsfeyw5y+NjP7ihQj7VX2JqiDyoMCRHIOjbkP7RLaKFFIhAhk+YSG9uP
X-Complaints-To: abuse@giganews.com
X-DMCA-Notifications: http://www.giganews.com/info/dmca.html
X-Abuse-and-DMCA-Info: Please be sure to forward a copy of ALL headers
X-Abuse-and-DMCA-Info: Otherwise we will be unable to process your complaint properly
X-Postfilter: 1.3.40
 by: Ross Finlayson - Wed, 24 Apr 2024 05:10 UTC

On 04/23/2024 08:07 PM, Ross Finlayson wrote:
> On 04/23/2024 07:08 PM, Sam wrote:
>> Ross Finlayson writes:
>>
>>> The idea is that this sort of approach to cooperative multithreading
>>> needs thread_local storage specifier, and, basically aspects to
>>> instrument the routine with its semantics of memoizing its results
>>> in the partial monad of the sub-routines' results in the re-launches,
>>> that the re-routine invokes all its asynchronous dependencies going
>>> along, those returning their memoized results if available else
>>> these null-throwing placeholders while launching themselves,
>>> that it results non-blocking routines in re-routines,
>>> with nothing at all about the semantics of asynchrony or callback,
>>> because in the aspect its implicit, in the language,
>>> in the defined behavior of the language and runtime.
>>>
>>> So, right, it's not runtime or library coroutines or in the language
>>> anything at all with the semantics of asynchrony, the idea is
>>> re-routines that can be sort of implemented in regards to there
>>> being virtual functions for these aspects, and thread_local storage,
>>> and threads, for a pattern (anti-pattern) of non-blocking re-routines.
>>>
>>> So, I suppose that would require C++ 11 for threads and thread_local,
>>> while, otherwise it would be a usual simple sort of portability layer.
>>
>> That's a little bit above my pay grade. I am focused on the narrow
>> question of "how to make an object that throws", upon "access". I'm very
>> confident that there is a C++ answer to this question, as soon as
>> "access" gets defined concisely, using C++ terms and terminology.
>>
>
> Zhengyi Fu pointed out that gcc has an option that for non-deferred
> signals that are trapped that they can be made to throw a std::exception
> in a non-portable manner, while, gcc is very widely implemented so it's
> pretty portable, -fnon-call-exceptions.
>
> Then, there's a notion that on Windows, there's ye olde Structured
> Exception Handling, which it is said can catch what would be segfault in
> the way that it is that it somehow employs setjmp/longjmp or rather
> as how SEH works, to make it so that dereferencing null would
> throw an exception instead of raising segfault.
>
> (Dereferencing/dereference-ing.)
>
> I would just hope to wonder and know that stack-unwinding or
> the usual defined behavior or throwing a std::exception or
> the behavior of throw was alright this way. What it seems
> is the signal handler just has synthesized a throw right there,
> as with regards to a bit of stack-magic where of course,
> "there is no magic, there is only logic", then that SEH
> accomplishes a same sort of thing. (Not sure how to
> have SEH handler throw a std::exception.)
>
> So, maybe there's, "a way", here still looking for,
> "a way, defined in the language".
>
>
> Hey thanks bud, I also am not quite sure otherwise how to go
> about "making an object, assignable to any lvalue according
> to a cast to its type, that when accessed, throws,
> unwinding the stack in normal defined behavior".
>
> It's appreciated that you are welcome to reject errancy, so, thanks.
> I would rather be told wrong than wrongly think right.
>
>
> So, we are still looking for a right sort of way, to
> make an object, as an rvalue assignable to any lvalue,
> that when "accessed", meaning any interaction at all
> that doesn't just treat it like an assignment, and thinking
> that assignment is only pointer or value assignment:
> that it throws.
>
> (Rather than causing a hardware fault and patching up
> that it's alright.)
>
>

It looks like it would get all involved with the copy and move
semantics of overloading '=', then I'm wondering if that
besides user-defined types of copy and move semantics
then there's something like this "library solution" its
"helper classes" what with regards to those being
having semantics how they deal with objects according
to those, of these C++ 11 lvalue and rvalue references
then separating what's "assignment" from what's "access".

There's a type trait it's said called remove_reference,
then though as regards to the declaration what results
that these "re-routines" their method would sort of
result being ignorant what's otherwise the intended
implementation of efficient copy and move semantics,
resulting assignment is sort of naive, then still there's
what about how to determine what is "access" of any
sort otherwise, and throwing on it.

https://www.open-std.org/jtc1/sc22/wg21/docs/papers/2004/n1690.html
https://en.cppreference.com/w/cpp/types/remove_reference

Then I'd sort of wonder whether template definition
would result convincing the compiler that a returned
rvalue, whether or not it was an lvalue, then with
respect to that getting assigned transitively, would
lose that as soon as it was an lvalue, here just trying
to figure out an object, cast-able to any type,
that wouldn't throw on usual copy and move assignments,
yet would throw on any otherwise access.

There's std::decay associated with std::bind,

https://en.cppreference.com/w/cpp/types/decay

that I wonder how it would perform, "type conversions",
resulting an object of some type.

https://en.cppreference.com/w/cpp/language/implicit_conversion

https://en.cppreference.com/w/cpp/language/value_category
https://en.cppreference.com/w/cpp/language/value_category#History

(There's a link to a paper from the author of the C++ book
about the terminology of these value categories terminology.pdf .)

Wow, value categories are widely expanded in C++ 11.

"The assignment operator (operator=) has special properties:
see copy assignment and move assignment for details. "
- https://en.cppreference.com/w/cpp/language/operators

I suppose in this kind of example, it's just that
"re-routines return std::future", a sort of least
accommodation of asynchronous routine.

Yet, then the first get()/wait(), in this example would throw,
to quit the re-routine as it would be re-alunched when
get()/wait() would actually be fulfilled, while I want entire
iterations to just invoke as if nothing was wrong or missing,
so that all the asynchronous requests get queued off as in
sort of automatically in parallel.

See, I want to write the routines, as usual, plain, synchronous
code, in the domain types and the library types, or standard,
and agnostic of asynchrony.

Then, std::future has that it can be extended and had returned
whatever implements std::future, yet get() which calls wait()
would have to return something that can be assigned or an
rvalue of some sort that's "MoveConstructible", of the library
type when it is, then to throw after the requests are iterated,
so that they are all pending and on the way.

Then, it seems sort of intractable to make for all the relevant
library types to return "an assignable rvalue", "that throws
on anything besides copy/move assignment", and that
otherwise the re-routines would just be all in domain types
that have it that they have sub-types each defined that
happen to behave this way, a bit of boilerplate.

The goal is "routines written in usual, plain, synchronous
code that also have implementations that are functionally
asynchronous, re-routines". Then if there's a way to make
it so that values can be assigned, and transitively, then that
those both have a way to determine whether they're fake
and "null-throwing", and also throw when they're accessed
by anything that isn't assignment, is a sort of anti-pattern
on the expectations of objects of a type, to solve a sort of
anti-pattern on the definition of routine that is synchronous.

Hey thanks. Figuring to just "return 0 and catch segfault",
is not-want, while there is a great perceived good thing in
"routine written as purely declarative and procedural, synchronous",
with, "re-routines according to the same flow-of-control,
make the asynchronous requests while returning un-usable objects".

In "the other language" I'm a lot less worried about it
because assignment passes nulls along and that's how
it is. If I was just dealing with pointers then assignment
passes nulls along and that's how it is. The modern way
of copy and move semantics vis-a-vis, return value optimization,
and that's always sort of bother me also, yet, having "in-place"
allocators and these things sort of not on the library types
and they have these ones, has that I'm looking for way to
make it so that library types have a constant value of their
type that passes along according to move and copy semantics,
that throws on anything else, a sort of "lazy throws quit".


Click here to read the complete article
Re: Q: how to make an object that throws

<d9a8168224d6e2ed50cc57e25ca044139ff6f3da.camel@gmail.com>

  copy mid

https://news.novabbs.org/devel/article-flat.php?id=3764&group=comp.lang.c%2B%2B#3764

  copy link   Newsgroups: comp.lang.c++
Path: i2pn2.org!i2pn.org!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: wyniijj5@gmail.com (wij)
Newsgroups: comp.lang.c++
Subject: Re: Q: how to make an object that throws
Date: Thu, 25 Apr 2024 02:56:30 +0800
Organization: A noiseless patient Spider
Lines: 132
Message-ID: <d9a8168224d6e2ed50cc57e25ca044139ff6f3da.camel@gmail.com>
References: <n6Ocnf_tkL8shbr7nZ2dnZfqn_qdnZ2d@giganews.com>
<87wmoon5d3.fsf@fuzy.me>
MIME-Version: 1.0
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
Injection-Date: Wed, 24 Apr 2024 20:56:31 +0200 (CEST)
Injection-Info: dont-email.me; posting-host="ceb311b92c34c920ae3ceeb25f33f361";
logging-data="2608277"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18dAlU8fio4LpS2KYdwFCZh"
User-Agent: Evolution 3.50.2 (3.50.2-1.fc39)
Cancel-Lock: sha1:4MV/CkklVPQP12B7HEQRqZTOsSM=
In-Reply-To: <87wmoon5d3.fsf@fuzy.me>
 by: wij - Wed, 24 Apr 2024 18:56 UTC

On Tue, 2024-04-23 at 11:08 +0800, Zhengyi Fu wrote:
> Ross Finlayson <ross.a.finlayson@gmail.com> writes:
>
> > Hello I hope I might consult your expertise, I'm wondering about
> > a use-case where for a given library object, to provide an instance
> > of same type, that on any access, throws an exception.
> >
> > The idea is that there's an idea in a different language where
> > the runtime throws a null_pointer_dereference exception
> > when dereferencing a null pointer, yet in C++ it's signal segfault.
> >
> > So, what I wonder about is how to make an object in C++,
> > of a given standard library type, and any arbitrary type,
> > that on any access, throws.
> >
> > I suppose I might static_cast an object yet I wonder how
> > to make it so then that any access to it throws.
> >
> > As you might imagine it's a use-case for exceptions
> > as part of flow-of-control, that in the other language
> > just is null yet in C++ would be for "an object of all types",
> > that throws on any access.
> >
>
> I believe there is no portable way to implement this.
>
> However, if you are running GCC on supported platforms, you can try
> the `-fnon-call-exceptions` option.
>
> --8<---------------cut here---------------start------------->8---
> // main.cpp
> #include <sys/types.h>
> #include <signal.h>
> #include <iostream>
> #include <exception>
>
> extern "C" void handle_signal(int signum) {
>   throw std::runtime_error("Invalid access");
> }
>
> int main()
> {
>   struct sigaction act;
>   act.sa_handler = &handle_signal;
>   sigemptyset(&act.sa_mask);
>   act.sa_flags = SA_NODEFER;
>   sigaction(SIGSEGV, &act, nullptr);
>
>   int *object = NULL;
>
>   try {
>     // write
>     *object = 100;
>   } catch (std::exception& exc) {
>     std::cerr << "Caught exception: " << exc.what() << '\n';
>   }
>
>   try {
>     // read
>     int value = *object;
>     std::cout << "value = "  << value << '\n';
>   } catch (std::exception& exc) {
>     std::cerr << "Caught exception: " << exc.what() << '\n';
>   }
> }
> --8<---------------cut here---------------end--------------->8---
>
> Compile the source file with
>
>   g++ -fnon-call-exceptions  -o test main.cpp
>
> Run ./test, it outputs
>
>   Caught exception: Invalid access
>   Caught exception: Invalid access
>

Convert to program using libwy C++ library:
(Thanks, learned something.)

//--------- t.cpp
#include <Wy.stdio.h>
#include <Wy.signal.h>

using namespace Wy;

static void handle_signal(int signum) {
cerr << "handle_signal(" << signum << ")" WY_ENDL;
WY_THROW( Errno(EFAULT) );
}

int main() {
Errno r;

if((r=sigaction(SIGSEGV, SigAct(handle_signal,SigSet(),SA_NODEFER)))!=Ok) {
WY_THROW(r);
}

int *object = NULL;

try {
// write
*object = 100;
}
catch (Errno& e) {
cerr << "Caught exception: " << wrd(e) << WY_ENDL;
}

try {
// read
int value = *object;
cout << "value = " << value << WY_ENDL;
}
catch (Errno& e) {
cerr << "Caught exception: " << wrd(e) << WY_ENDL;
}

};

//------------------------------
[]$ g++ -fnon-call-exceptions t.cpp -lwy
[]$ ./a.out
handle_signal(11)
Caught exception: Bad address, t.cpp(53)
handle_signal(11)
Caught exception: Bad address, t.cpp(53)

Re: Q: how to make an object that throws

<6MqdnSF2kuCuyrT7nZ2dnZfqn_GdnZ2d@giganews.com>

  copy mid

https://news.novabbs.org/devel/article-flat.php?id=3765&group=comp.lang.c%2B%2B#3765

  copy link   Newsgroups: comp.lang.c++
Path: i2pn2.org!i2pn.org!weretis.net!feeder6.news.weretis.net!border-1.nntp.ord.giganews.com!nntp.giganews.com!Xl.tags.giganews.com!local-2.nntp.ord.giganews.com!news.giganews.com.POSTED!not-for-mail
NNTP-Posting-Date: Wed, 24 Apr 2024 19:02:11 +0000
Subject: Re: Q: how to make an object that throws
Newsgroups: comp.lang.c++
References: <n6Ocnf_tkL8shbr7nZ2dnZfqn_qdnZ2d@giganews.com>
<87wmoon5d3.fsf@fuzy.me>
<d9a8168224d6e2ed50cc57e25ca044139ff6f3da.camel@gmail.com>
From: ross.a.finlayson@gmail.com (Ross Finlayson)
Date: Wed, 24 Apr 2024 12:02:17 -0700
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101
Thunderbird/38.6.0
MIME-Version: 1.0
In-Reply-To: <d9a8168224d6e2ed50cc57e25ca044139ff6f3da.camel@gmail.com>
Content-Type: text/plain; charset=utf-8; format=flowed
Content-Transfer-Encoding: 7bit
Message-ID: <6MqdnSF2kuCuyrT7nZ2dnZfqn_GdnZ2d@giganews.com>
Lines: 228
X-Usenet-Provider: http://www.giganews.com
X-Trace: sv3-17ayGeIlnb76+OMYZfmPJ6nneL3BCK9p72WzTQWJA1hI34ThL61opeY8Nsdd/JECiAY9/SDazy2u9YM!2yv8G1MQtuU6chomD39saR7SwtD3LyEL3BkvovEbg7t70Xi30mObfroCtLLwG+X9GnSRERUnpVUY
X-Complaints-To: abuse@giganews.com
X-DMCA-Notifications: http://www.giganews.com/info/dmca.html
X-Abuse-and-DMCA-Info: Please be sure to forward a copy of ALL headers
X-Abuse-and-DMCA-Info: Otherwise we will be unable to process your complaint properly
X-Postfilter: 1.3.40
 by: Ross Finlayson - Wed, 24 Apr 2024 19:02 UTC

On 04/24/2024 11:56 AM, wij wrote:
> On Tue, 2024-04-23 at 11:08 +0800, Zhengyi Fu wrote:
>> Ross Finlayson <ross.a.finlayson@gmail.com> writes:
>>
>>> Hello I hope I might consult your expertise, I'm wondering about
>>> a use-case where for a given library object, to provide an instance
>>> of same type, that on any access, throws an exception.
>>>
>>> The idea is that there's an idea in a different language where
>>> the runtime throws a null_pointer_dereference exception
>>> when dereferencing a null pointer, yet in C++ it's signal segfault.
>>>
>>> So, what I wonder about is how to make an object in C++,
>>> of a given standard library type, and any arbitrary type,
>>> that on any access, throws.
>>>
>>> I suppose I might static_cast an object yet I wonder how
>>> to make it so then that any access to it throws.
>>>
>>> As you might imagine it's a use-case for exceptions
>>> as part of flow-of-control, that in the other language
>>> just is null yet in C++ would be for "an object of all types",
>>> that throws on any access.
>>>
>>
>> I believe there is no portable way to implement this.
>>
>> However, if you are running GCC on supported platforms, you can try
>> the `-fnon-call-exceptions` option.
>>
>> --8<---------------cut here---------------start------------->8---
>> // main.cpp
>> #include <sys/types.h>
>> #include <signal.h>
>> #include <iostream>
>> #include <exception>
>>
>> extern "C" void handle_signal(int signum) {
>> throw std::runtime_error("Invalid access");
>> }
>>
>> int main()
>> {
>> struct sigaction act;
>> act.sa_handler = &handle_signal;
>> sigemptyset(&act.sa_mask);
>> act.sa_flags = SA_NODEFER;
>> sigaction(SIGSEGV, &act, nullptr);
>>
>> int *object = NULL;
>>
>> try {
>> // write
>> *object = 100;
>> } catch (std::exception& exc) {
>> std::cerr << "Caught exception: " << exc.what() << '\n';
>> }
>>
>> try {
>> // read
>> int value = *object;
>> std::cout << "value = " << value << '\n';
>> } catch (std::exception& exc) {
>> std::cerr << "Caught exception: " << exc.what() << '\n';
>> }
>> }
>> --8<---------------cut here---------------end--------------->8---
>>
>> Compile the source file with
>>
>> g++ -fnon-call-exceptions -o test main.cpp
>>
>> Run ./test, it outputs
>>
>> Caught exception: Invalid access
>> Caught exception: Invalid access
>>
>
> Convert to program using libwy C++ library:
> (Thanks, learned something.)
>
> //--------- t.cpp
> #include <Wy.stdio.h>
> #include <Wy.signal.h>
>
> using namespace Wy;
>
> static void handle_signal(int signum) {
> cerr << "handle_signal(" << signum << ")" WY_ENDL;
> WY_THROW( Errno(EFAULT) );
> }
>
> int main() {
> Errno r;
>
> if((r=sigaction(SIGSEGV, SigAct(handle_signal,SigSet(),SA_NODEFER)))!=Ok) {
> WY_THROW(r);
> }
>
> int *object = NULL;
>
> try {
> // write
> *object = 100;
> }
> catch (Errno& e) {
> cerr << "Caught exception: " << wrd(e) << WY_ENDL;
> }
>
> try {
> // read
> int value = *object;
> cout << "value = " << value << WY_ENDL;
> }
> catch (Errno& e) {
> cerr << "Caught exception: " << wrd(e) << WY_ENDL;
> }
>
> };
>
> //------------------------------
> []$ g++ -fnon-call-exceptions t.cpp -lwy
> []$ ./a.out
> handle_signal(11)
> Caught exception: Bad address, t.cpp(53)
> handle_signal(11)
> Caught exception: Bad address, t.cpp(53)
>
>
>

It seems the current these days is "not exceptions", that
instead the drift is toward "Result<T, E>" or "std::expected<T, E>"
as for a sort of poor-man's covariant return types, combined
with a sort of type-enforced error handling as good old error
codes vis-a-vis usual old notions of reserved ranges in integer
return codes. (... Cluttering everything everywhere with
handler code.)

What with C++ "removing exception specifications" it's sort
of figured they won't be back, and all that remains is throw
and nothrow, renamed noexcept. (... Cluttering the line.)

Covariant return types is a usual sort of thing not present
in usual languages. Dealing with "variant" and "union"
and these type things, as representing "objects" of the
usual sorts of language of the data in, "data", or rather
associative arrays usually but really a union or variant
type, which is a union type with a variant type tag,
or "nested object data", it's not an usual idea for
something like "the routine returns an instance of T"
and "the routine throws an exception which may
contain an instance of E" vis-a-vis "the routine returns
an expected<T, E> which has either/or T, E, hope-ful-ly".

So yeah though exception-specification really makes
for an entire complement of things about the types
of the signatures, expected state before/after and
how it's expected to be broken and how it's expected
to be recoverable and howso it would unwind the stack,
from where-ever in the entire stack an error arises,
it seems just dropping exception-specification in C++ 20,
results a reduced expressitivity of the specification of the
intent, and, the intent of the specification.

"Oh, well you just change everything back to
checking the status code everywhere." "Oh, so,
what happens when some routine results a fault?"
"Die." "Well that seems a bit extreme...,
I'm expecting these exceptions."

Just seems they figure to declutter the exception-specification
to clutter all the signature argument and return types as expected
and just usually die unexpectedly. I don't get it. I mean, I get it,
yet, the exception-specification really expresses the intent
and what it can handle, and anywhere in the stack what must be.
Then, unrecoverable errors or the "on the way to the exit",
it sort of helps usually "let me log you on your way out".

For plain, neat, usual, un-cluttered happy-case synchronous routine.
(And type-safe covariant return, fault, and exception handling.)

I mean if it's just like "fork C++, one with exception-specifications,
and a base hierarchy or recoverable and unrecoverable exceptions,
if I was dieing I'd want to get the tag of the flaming bus that hit me".
I.e., "panic", is not an option.

Let's see, what does Eiffel think about it.

https://www.eiffel.org/doc/solutions/Exception_Mechanism

Eiffel is like Ruby and has exceptions and "raise/rescue" like "try/catch".
(... And for "finally".)

https://en.wikipedia.org/wiki/Eiffel_(programming_language)

"Exception handling in Eiffel is based on the
principles of design by contract. For example,
an exception occurs when a routine's caller
fails to satisfy a precondition, or when a
routine cannot ensure a promised postcondition."
-
https://en.wikipedia.org/wiki/Eiffel_(programming_language)#Exception_handling

Then, I'd just aver the re-routines don't throw exceptions for
flow-of-control, as rather they just indicate a pending unsatisfied
postcondition which is retryable.

....With exceptions, and when to fail, for example when the time is expired.
.... All non-blockingly.

https://en.wikibooks.org/wiki/Ada_Programming/Exceptions

"When an exception occurs, the normal flow of execution is abandoned
and the exception is handed up the call sequence until a matching
handler is found."

Ada throws exceptions ..., these things say exceptions are the
way of making "robustness" after something like RAII makes "correctness".

When "panic and die" isn't correct, ....

Re: Q: how to make an object that throws

<object-20240424202505@ram.dialup.fu-berlin.de>

  copy mid

https://news.novabbs.org/devel/article-flat.php?id=3767&group=comp.lang.c%2B%2B#3767

  copy link   Newsgroups: comp.lang.c++
Path: i2pn2.org!i2pn.org!news.swapon.de!fu-berlin.de!uni-berlin.de!not-for-mail
From: ram@zedat.fu-berlin.de (Stefan Ram)
Newsgroups: comp.lang.c++
Subject: Re: Q: how to make an object that throws
Date: 24 Apr 2024 19:26:26 GMT
Organization: Stefan Ram
Lines: 15
Expires: 1 Feb 2025 11:59:58 GMT
Message-ID: <object-20240424202505@ram.dialup.fu-berlin.de>
References: <n6Ocnf_tkL8shbr7nZ2dnZfqn_qdnZ2d@giganews.com> <87wmoon5d3.fsf@fuzy.me>
Mime-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
X-Trace: news.uni-berlin.de rn1M5/MbwS6qg4WcH15bQAIsWfC9j/TqZWONWezsFRcWIs
Cancel-Lock: sha1:2aQT2czhmvntnl8tNgK2SFT9udo= sha256:eCxVZaWDikUDPcBDN0S7VR/L+/GcDJ8I3XHcbwVgapo=
X-Copyright: (C) Copyright 2024 Stefan Ram. All rights reserved.
Distribution through any means other than regular usenet
channels is forbidden. It is forbidden to publish this
article in the Web, to change URIs of this article into links,
and to transfer the body without this notice, but quotations
of parts in other Usenet posts are allowed.
X-No-Archive: Yes
Archive: no
X-No-Archive-Readme: "X-No-Archive" is set, because this prevents some
services to mirror the article in the web. But the article may
be kept on a Usenet archive server with only NNTP access.
X-No-Html: yes
Content-Language: en-US
 by: Stefan Ram - Wed, 24 Apr 2024 19:26 UTC

Zhengyi Fu <i@fuzy.me> wrote or quoted:
>int *object = NULL;

This seems to be what's helping the OP, but when you consider
that the subject line is "how to make an object that throws",
you'd actually have to say that the thrower here is not an
object, but rather the /absence of an object/.

This of course has to do with how objects are specified.

In C++, an expression can stand directly for an object, so
an assignment copies that object. In other languages, objects
are always implicitly specified by references/pointers, and
an assignment copies that reference/pointer. This can make it
appear sometimes as if a reference/pointer is an object.

Re: Q: how to make an object that throws

<EyydneQoZr6e77T7nZ2dnZfqnPWdnZ2d@giganews.com>

  copy mid

https://news.novabbs.org/devel/article-flat.php?id=3770&group=comp.lang.c%2B%2B#3770

  copy link   Newsgroups: comp.lang.c++
Path: i2pn2.org!i2pn.org!weretis.net!feeder9.news.weretis.net!border-2.nntp.ord.giganews.com!nntp.giganews.com!Xl.tags.giganews.com!local-1.nntp.ord.giganews.com!news.giganews.com.POSTED!not-for-mail
NNTP-Posting-Date: Wed, 24 Apr 2024 20:56:35 +0000
Subject: Re: Q: how to make an object that throws
Newsgroups: comp.lang.c++
References: <n6Ocnf_tkL8shbr7nZ2dnZfqn_qdnZ2d@giganews.com>
<87wmoon5d3.fsf@fuzy.me> <object-20240424202505@ram.dialup.fu-berlin.de>
From: ross.a.finlayson@gmail.com (Ross Finlayson)
Date: Wed, 24 Apr 2024 13:56:44 -0700
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101
Thunderbird/38.6.0
MIME-Version: 1.0
In-Reply-To: <object-20240424202505@ram.dialup.fu-berlin.de>
Content-Type: text/plain; charset=utf-8; format=flowed
Content-Transfer-Encoding: 7bit
Message-ID: <EyydneQoZr6e77T7nZ2dnZfqnPWdnZ2d@giganews.com>
Lines: 214
X-Usenet-Provider: http://www.giganews.com
X-Trace: sv3-88Bna+Je/yxPR7YZPFXFmAK4gFAciUMgKP/kz4vOjvLgMvs4FCShlZjo2C+ZIz0HaJPvBS8mnsD18mL!HSPx8sL6hO5mEGiomUMFQajbAMek6qEKrt1rgeIlvkWdkk6zQNEkfrPzxg/a6eUPg9QoS6E3Ll8i
X-Complaints-To: abuse@giganews.com
X-DMCA-Notifications: http://www.giganews.com/info/dmca.html
X-Abuse-and-DMCA-Info: Please be sure to forward a copy of ALL headers
X-Abuse-and-DMCA-Info: Otherwise we will be unable to process your complaint properly
X-Postfilter: 1.3.40
 by: Ross Finlayson - Wed, 24 Apr 2024 20:56 UTC

On 04/24/2024 12:26 PM, Stefan Ram wrote:
> Zhengyi Fu <i@fuzy.me> wrote or quoted:
>> int *object = NULL;
>
> This seems to be what's helping the OP, but when you consider
> that the subject line is "how to make an object that throws",
> you'd actually have to say that the thrower here is not an
> object, but rather the /absence of an object/.
>
> This of course has to do with how objects are specified.
>
> In C++, an expression can stand directly for an object, so
> an assignment copies that object. In other languages, objects
> are always implicitly specified by references/pointers, and
> an assignment copies that reference/pointer. This can make it
> appear sometimes as if a reference/pointer is an object.
>

One thing I wonder, is, that if move semantics "may"
result that the rvalue is un-usable, or copying the
member pointers from the temporary to the object
in the scope to be destructed when the scope concludes,
making unusable the temporary by nulling its member pointers,
then I wonder if that's allowed and whether it "must",
so make un-usable the rvalue, and whether, also, that
copy and move semantics on un-usable objects, result,
the same nulled-out member-pointer, un-usable objects,
though being assigned transitively alright.

Then I read there's a current specification incoming to
the language that would prevent objects from being
copied/moved from nulled-out member-pointer
un-usable objects, so it's not something reliable when
the guarantee would otherwise be "pass along this
object its reference or reference reference or pointer
or scalar built-in value, assignment" while "as an un-usable
nulled-out member-pointer object any access is expected
to segfault".

I.e., I wonder if I can return a dummy by constructing an
empty, invoking a move off it to null-out its member-pointers,
then return that from the routine so that then its assignment
as from its value category, resulting a sort of "exploding dummy".

I.e., what's in mind is a sort of "experimental::unusable<T>" that is
sort of like "std::identity<T>" or as an instance of T, that doesn't
fault on assignment, but faults on otherwise access on its
members, or member-pointers.

What I figure is that the re-routine is a pattern for cooperative
multithreading, with usual and plain synchronous definition of
flow-of-control, and in types and in the language, that is always a
task, that the originator/initiator of the re-routine, puts on a task
queue TQ the re-routine, then that the re-routine, "falls through",
executing, that the re-routines it calls, either get a usable object and
return an unusable return value, or as what they block and compute, or
get an unusable object and throw "quit".

The idea is that the very first time a re-routine is called with a
usable object, it kicks off its asynchronous invocation, while in the
thread_local that it has in the mixin class of re-routine, in the
"monad" of the accumulating usable return values, it stashes what it
constructs as an "unusable" object. So, there are sub-routines as
plain routine, and sub-routines as blocking or non-blocking
implementors, all the same code the same routine.

The callback of the asynchronous call, with a handle to the monad and
the invoker's path in the monad, and to the TQ, populates the monad (the
accumulating results) and (re-)submits the re-routine to the TQ, which
repeats or complete. When complete, if it is an original re-routine,
invokes the callback of the originating task, or if it is a
sub-re-routine, it adds the invoking re-routine, back to the TQ, which
now again "falls through" yet getting the usable object from the monad,
instead of the unusable object, and continues.

void rr0(int i1) {
string s1 = rr1(i1);
string s2 = rr2(i1);
string s3 = rr3(i1);

string s4 = rr4(s1, s2, s3);
}

I sort of figure that rr 1, 2, 3, "fall through", where i1 is usable,
make their asynchronous requests, and return "unusable" s 1 2 3.

Then, rr4 gets any unusable s 1 2 3 and throws quit, the re-routine
exits (throws, never blocking). The originating task queue TQ forgets
all about it. (Though, one figures that its timeouts are in the queue
behind it.)

So, at some point, rr 1, 2, 3 asynchronous requests, return and their
callback populates rr 1, 2, 3's monad, which is a member of the original
re-routine, so that now rr 1, 2, 3 have their return values (or,
exceptions) in the monad. The callback also throws the sub-re-routines'
super-re-routine, which happens to be the originating routine, back on
the TQ. When a consumer picks it off the TQ, it runs through again.

void rr0(int i1) {
string s1 = rr1(i1);
string s2 = rr2(i1);
string s3 = rr3(i1);

string s4 = rr4(s1, s2, s3);

return s4;
}

It starts all over again and runs through again, though now one or more
of s 1 2 3 are usable and in the monad thread_local, sp rr4 checks its
inputs and either throws quit or not, and if it doesn't, then it returns
an (unusable) sf4, having made its asynchronous request, the callback of
which will populate its monad and re-submit it's caller to the Task Queue.

Eventually then rr0 completes, or, throws anything besides a "quit",
"postcondition_pending". The originator takes that and calls back the
original callback initially constructed with the re-routine specification.

So, it expects something somewhere to accept a callback, then that the
idea is that the callbacks are non-blocking, and, the re-routines are
non-blocking, so whatever makes the originating calls, must have its own
thread(s), and whatever fulfills the asynchronous requests, must have
its own thread(s). Then all the re-routines get one thread, in as to
whether "re-routines are re-entrant". (It's figured that when a
re-routine concludes then its monad is marked a particular unusable
"concluded".)

So, what I hope to figure out for C++, is, a sort of
experimental::unusable<T>, that's MoveConstructible and
CopyConstructible, for the library objects, the standard objects, so
that the re-routine, can have any sort of other code in it, library
code, with the expectation that the contents of collections are always
in the same order, with regards to that the first time a sub-re-routine
is invoked with usable arguments, then its result from its monad will
always be as of those.

void rr0(int i1) {

// any library code

string s1 = rr1(i1);
string s2 = rr2(i1);
string s3 = rr3(i1);

// any library code

string s4 = rr4(s1, s2, s3);

// any library code

return s4;
}

Then, I understand that the library code will be run each time the
re-routine is re-run, and don't much care, if it's non-blocking, or when
it gets an unusable object that it throws quit.

If the library code is actually pretty heavyweight, then the idea is to
put it into a sub-re-routine, then it will just be run once otherwise
acting just like a usual sub-re-routine.

void rr0(int i1) {
string s1 = rr1(i1);
string s2 = rr2(i1);
string s3 = rr3(i1);

string s4 = rr4(s1, s2, s3);

return s4;
}

void rr1(int i1) {
idiomatic_boxed<double> d1 = rr1a(i1);
idiomatic_boxed<double> d2 = rr1b(i1);
idiomatic_boxed<double> d3 = rr1c(i1);
idiomatic_boxed<double> d4 = rr1d(i1);

return rr1s(d1, d2,d3, d4);
}

See, I sort of expect that this way, it looks just like a blocking,
synchronous routine, and for example could be implemented thusly, for a
thread that expects to just run and block its way through.

Also, the re-routine can run sub-re-routines for various values, they
get stored in the monad basically by serial order because according to
the same flow-of-control they always get invoked for the first time in
the same order, finding their spot in the monad to populate their return
value, while finding their depth and serial order in the monad where to
call back out homeward to the origin of the original re-routine.

So, I'm looking for in C++ "an object that throws", that is
CopyConstructible and MoveConstructible for any type, yet is otherwise
unusable, and can be determined unusable either by invoking anything on
it and throwing, or some mixin to detect it's unusable, some
"experimental:unusable<T>".

Re: Q: how to make an object that throws

<86bk5xw3o5.fsf@linuxsc.com>

  copy mid

https://news.novabbs.org/devel/article-flat.php?id=3781&group=comp.lang.c%2B%2B#3781

  copy link   Newsgroups: comp.lang.c++
Path: i2pn2.org!i2pn.org!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: tr.17687@z991.linuxsc.com (Tim Rentsch)
Newsgroups: comp.lang.c++
Subject: Re: Q: how to make an object that throws
Date: Thu, 25 Apr 2024 14:08:58 -0700
Organization: A noiseless patient Spider
Lines: 25
Message-ID: <86bk5xw3o5.fsf@linuxsc.com>
References: <n6Ocnf_tkL8shbr7nZ2dnZfqn_qdnZ2d@giganews.com> <87wmoon5d3.fsf@fuzy.me> <object-20240424202505@ram.dialup.fu-berlin.de>
MIME-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Injection-Date: Thu, 25 Apr 2024 23:08:58 +0200 (CEST)
Injection-Info: dont-email.me; posting-host="4d027413e75dd4b7b3c31e0f92925554";
logging-data="3382317"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/wFVGkzp8UpEVAwBb5Wlmj3hBevP5Ocqw="
User-Agent: Gnus/5.11 (Gnus v5.11) Emacs/22.4 (gnu/linux)
Cancel-Lock: sha1:JtsWcNXrNAan6IwOh4dffdfrQH0=
sha1:JD8Pe2FK43tEWTOy5gra84An8Ls=
 by: Tim Rentsch - Thu, 25 Apr 2024 21:08 UTC

ram@zedat.fu-berlin.de (Stefan Ram) writes:

> Zhengyi Fu <i@fuzy.me> wrote or quoted:
>
>> int *object = NULL;
>
> This seems to be what's helping the OP, but when you consider
> that the subject line is "how to make an object that throws",
> you'd actually have to say that the thrower here is not an
> object, but rather the /absence of an object/.
>
> This of course has to do with how objects are specified.
>
> In C++, an expression can stand directly for an object, so
> an assignment copies that object. In other languages,

In some other languages. Certainly not all other languages.

> objects
> are always implicitly specified by references/pointers, and
> an assignment copies that reference/pointer.

Some languages that use pointer semantics rather than using
"objects" directly don't have a way to do assignment, so the
question of what is copied is moot.

Re: Q: how to make an object that throws

<XJmcnXG6M66riLD7nZ2dnZfqnPqdnZ2d@giganews.com>

  copy mid

https://news.novabbs.org/devel/article-flat.php?id=3787&group=comp.lang.c%2B%2B#3787

  copy link   Newsgroups: comp.lang.c++
Path: i2pn2.org!i2pn.org!weretis.net!feeder9.news.weretis.net!border-2.nntp.ord.giganews.com!nntp.giganews.com!Xl.tags.giganews.com!local-2.nntp.ord.giganews.com!news.giganews.com.POSTED!not-for-mail
NNTP-Posting-Date: Sat, 27 Apr 2024 15:09:41 +0000
Subject: Re: Q: how to make an object that throws
Newsgroups: comp.lang.c++
References: <n6Ocnf_tkL8shbr7nZ2dnZfqn_qdnZ2d@giganews.com>
<87wmoon5d3.fsf@fuzy.me> <object-20240424202505@ram.dialup.fu-berlin.de>
<EyydneQoZr6e77T7nZ2dnZfqnPWdnZ2d@giganews.com>
From: ross.a.finlayson@gmail.com (Ross Finlayson)
Date: Sat, 27 Apr 2024 08:09:32 -0700
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101
Thunderbird/38.6.0
MIME-Version: 1.0
In-Reply-To: <EyydneQoZr6e77T7nZ2dnZfqnPWdnZ2d@giganews.com>
Content-Type: text/plain; charset=utf-8; format=flowed
Content-Transfer-Encoding: 7bit
Message-ID: <XJmcnXG6M66riLD7nZ2dnZfqnPqdnZ2d@giganews.com>
Lines: 279
X-Usenet-Provider: http://www.giganews.com
X-Trace: sv3-Z6c0KogBgPM/naxKGnBMB3mhtWI40IqPx52zDgIVaufxsKFjeiR2asaJqAb3TPEQsCAfG3b4BowyGEr!8SOHb8YLTQeAWcumaF007Ql8QyL+9h/+3lFZyCloiDf1xUOWS0wIOzAFUD6LrIGYWi8pgGwP9bz0
X-Complaints-To: abuse@giganews.com
X-DMCA-Notifications: http://www.giganews.com/info/dmca.html
X-Abuse-and-DMCA-Info: Please be sure to forward a copy of ALL headers
X-Abuse-and-DMCA-Info: Otherwise we will be unable to process your complaint properly
X-Postfilter: 1.3.40
 by: Ross Finlayson - Sat, 27 Apr 2024 15:09 UTC

On 04/24/2024 01:56 PM, Ross Finlayson wrote:
> On 04/24/2024 12:26 PM, Stefan Ram wrote:
>> Zhengyi Fu <i@fuzy.me> wrote or quoted:
>>> int *object = NULL;
>>
>> This seems to be what's helping the OP, but when you consider
>> that the subject line is "how to make an object that throws",
>> you'd actually have to say that the thrower here is not an
>> object, but rather the /absence of an object/.
>>
>> This of course has to do with how objects are specified.
>>
>> In C++, an expression can stand directly for an object, so
>> an assignment copies that object. In other languages, objects
>> are always implicitly specified by references/pointers, and
>> an assignment copies that reference/pointer. This can make it
>> appear sometimes as if a reference/pointer is an object.
>>
>
>
> One thing I wonder, is, that if move semantics "may"
> result that the rvalue is un-usable, or copying the
> member pointers from the temporary to the object
> in the scope to be destructed when the scope concludes,
> making unusable the temporary by nulling its member pointers,
> then I wonder if that's allowed and whether it "must",
> so make un-usable the rvalue, and whether, also, that
> copy and move semantics on un-usable objects, result,
> the same nulled-out member-pointer, un-usable objects,
> though being assigned transitively alright.
>
> Then I read there's a current specification incoming to
> the language that would prevent objects from being
> copied/moved from nulled-out member-pointer
> un-usable objects, so it's not something reliable when
> the guarantee would otherwise be "pass along this
> object its reference or reference reference or pointer
> or scalar built-in value, assignment" while "as an un-usable
> nulled-out member-pointer object any access is expected
> to segfault".
>
> I.e., I wonder if I can return a dummy by constructing an
> empty, invoking a move off it to null-out its member-pointers,
> then return that from the routine so that then its assignment
> as from its value category, resulting a sort of "exploding dummy".
>
> I.e., what's in mind is a sort of "experimental::unusable<T>" that is
> sort of like "std::identity<T>" or as an instance of T, that doesn't
> fault on assignment, but faults on otherwise access on its
> members, or member-pointers.
>
>
> What I figure is that the re-routine is a pattern for cooperative
> multithreading, with usual and plain synchronous definition of
> flow-of-control, and in types and in the language, that is always a
> task, that the originator/initiator of the re-routine, puts on a task
> queue TQ the re-routine, then that the re-routine, "falls through",
> executing, that the re-routines it calls, either get a usable object and
> return an unusable return value, or as what they block and compute, or
> get an unusable object and throw "quit".
>
> The idea is that the very first time a re-routine is called with a
> usable object, it kicks off its asynchronous invocation, while in the
> thread_local that it has in the mixin class of re-routine, in the
> "monad" of the accumulating usable return values, it stashes what it
> constructs as an "unusable" object. So, there are sub-routines as
> plain routine, and sub-routines as blocking or non-blocking
> implementors, all the same code the same routine.
>
> The callback of the asynchronous call, with a handle to the monad and
> the invoker's path in the monad, and to the TQ, populates the monad (the
> accumulating results) and (re-)submits the re-routine to the TQ, which
> repeats or complete. When complete, if it is an original re-routine,
> invokes the callback of the originating task, or if it is a
> sub-re-routine, it adds the invoking re-routine, back to the TQ, which
> now again "falls through" yet getting the usable object from the monad,
> instead of the unusable object, and continues.
>
> void rr0(int i1) {
> string s1 = rr1(i1);
> string s2 = rr2(i1);
> string s3 = rr3(i1);
>
> string s4 = rr4(s1, s2, s3);
> }
>
> I sort of figure that rr 1, 2, 3, "fall through", where i1 is usable,
> make their asynchronous requests, and return "unusable" s 1 2 3.
>
> Then, rr4 gets any unusable s 1 2 3 and throws quit, the re-routine
> exits (throws, never blocking). The originating task queue TQ forgets
> all about it. (Though, one figures that its timeouts are in the queue
> behind it.)
>
> So, at some point, rr 1, 2, 3 asynchronous requests, return and their
> callback populates rr 1, 2, 3's monad, which is a member of the original
> re-routine, so that now rr 1, 2, 3 have their return values (or,
> exceptions) in the monad. The callback also throws the sub-re-routines'
> super-re-routine, which happens to be the originating routine, back on
> the TQ. When a consumer picks it off the TQ, it runs through again.
>
> void rr0(int i1) {
> string s1 = rr1(i1);
> string s2 = rr2(i1);
> string s3 = rr3(i1);
>
> string s4 = rr4(s1, s2, s3);
>
> return s4;
> }
>
>
> It starts all over again and runs through again, though now one or more
> of s 1 2 3 are usable and in the monad thread_local, sp rr4 checks its
> inputs and either throws quit or not, and if it doesn't, then it returns
> an (unusable) sf4, having made its asynchronous request, the callback of
> which will populate its monad and re-submit it's caller to the Task Queue.
>
> Eventually then rr0 completes, or, throws anything besides a "quit",
> "postcondition_pending". The originator takes that and calls back the
> original callback initially constructed with the re-routine specification.
>
> So, it expects something somewhere to accept a callback, then that the
> idea is that the callbacks are non-blocking, and, the re-routines are
> non-blocking, so whatever makes the originating calls, must have its own
> thread(s), and whatever fulfills the asynchronous requests, must have
> its own thread(s). Then all the re-routines get one thread, in as to
> whether "re-routines are re-entrant". (It's figured that when a
> re-routine concludes then its monad is marked a particular unusable
> "concluded".)
>
>
> So, what I hope to figure out for C++, is, a sort of
> experimental::unusable<T>, that's MoveConstructible and
> CopyConstructible, for the library objects, the standard objects, so
> that the re-routine, can have any sort of other code in it, library
> code, with the expectation that the contents of collections are always
> in the same order, with regards to that the first time a sub-re-routine
> is invoked with usable arguments, then its result from its monad will
> always be as of those.
>
> void rr0(int i1) {
>
> // any library code
>
> string s1 = rr1(i1);
> string s2 = rr2(i1);
> string s3 = rr3(i1);
>
> // any library code
>
> string s4 = rr4(s1, s2, s3);
>
> // any library code
>
> return s4;
> }
>
> Then, I understand that the library code will be run each time the
> re-routine is re-run, and don't much care, if it's non-blocking, or when
> it gets an unusable object that it throws quit.
>
> If the library code is actually pretty heavyweight, then the idea is to
> put it into a sub-re-routine, then it will just be run once otherwise
> acting just like a usual sub-re-routine.
>
> void rr0(int i1) {
> string s1 = rr1(i1);
> string s2 = rr2(i1);
> string s3 = rr3(i1);
>
> string s4 = rr4(s1, s2, s3);
>
> return s4;
> }
>
> void rr1(int i1) {
> idiomatic_boxed<double> d1 = rr1a(i1);
> idiomatic_boxed<double> d2 = rr1b(i1);
> idiomatic_boxed<double> d3 = rr1c(i1);
> idiomatic_boxed<double> d4 = rr1d(i1);
>
> return rr1s(d1, d2,d3, d4);
> }
>
> See, I sort of expect that this way, it looks just like a blocking,
> synchronous routine, and for example could be implemented thusly, for a
> thread that expects to just run and block its way through.
>
> Also, the re-routine can run sub-re-routines for various values, they
> get stored in the monad basically by serial order because according to
> the same flow-of-control they always get invoked for the first time in
> the same order, finding their spot in the monad to populate their return
> value, while finding their depth and serial order in the monad where to
> call back out homeward to the origin of the original re-routine.
>
> So, I'm looking for in C++ "an object that throws", that is
> CopyConstructible and MoveConstructible for any type, yet is otherwise
> unusable, and can be determined unusable either by invoking anything on
> it and throwing, or some mixin to detect it's unusable, some
> "experimental:unusable<T>".
>
>
>
>


Click here to read the complete article
1
server_pubkey.txt

rocksolid light 0.9.81
clearnet tor