On Thursday, 18 June 2020 at 17:39:44 UTC, Denis wrote:
I should add that this one made me laugh though, giving
flashbacks to that horrible "not speak" of the early 90s:
if ( configfile.isFile.not ) ...
LOL
Approve Yoda does.
On Thursday, 18 June 2020 at 17:57:49 UTC, Ali Çehreli wrote:
Here is an earlier experiment of nested templates, which may be
useful in this case.
:
I think you should be able to pass callables as 'alias'
template arguments
Sounds good. This gives me an opportunity to learn how nested
On 6/18/20 5:13 AM, Denis wrote:
> Templates offer a clean syntax
Here is an earlier experiment of nested templates, which may be useful
in this case. This is unrelated to your problem but the syntax can be
pretty readable with templates:
// If there are template arguments, then the result
On Thursday, 18 June 2020 at 12:50:35 UTC, Stanislav Blinov wrote:
No, there isn't a way to write an operator.
OK, first choice eliminated.
On Thursday, 18 June 2020 at 13:57:39 UTC, Dukc wrote:
No reason to use templates here
pragma(inline, true) auto not(bool cond) { return !cond(); }
I
On Thursday, 18 June 2020 at 13:58:33 UTC, Dukc wrote:
On Thursday, 18 June 2020 at 13:57:39 UTC, Dukc wrote:
if (not!(abra && cadabra)) ...
if (not(abra && cadabra)) ...
Which is a quite a complicated way to write
if (!(abra && cadabra)) ...
On Thursday, 18 June 2020 at 13:57:39 UTC, Dukc wrote:
No reason to use templates here
Pff. Me no think straight. -.-
On Thursday, 18 June 2020 at 12:50:35 UTC, Stanislav Blinov wrote:
auto not(alias cond)() { return !cond(); }
if (not!(() => abra && cadabra)) ...
but that is indeed even less readable.
No reason to use templates here
```
pragma(inline, true) auto not(bool cond) { return !cond(); }
if
On Thursday, 18 June 2020 at 13:57:39 UTC, Dukc wrote:
if (not!(abra && cadabra)) ...
if (not(abra && cadabra)) ...
On Thursday, 18 June 2020 at 12:13:21 UTC, Denis wrote:
THE ESSENTIAL QUESTION
Is there a way to write an `unless` operator that would allow
the condition to be expressed in an affirmative sense? It would
be used like `if`, i.e. something like:
unless ( ) {
; // Or even:
Let me clarify the requirements and rephrase the question --
REQUIREMENTS
`assert`, `enforce` and the `unless` function I wrote (above) all
allow the condition to be expressed in an affirmative sense, and
they also achieve the goal of readability. These are the initial
requirements.
On 6/17/20 4:46 PM, Denis wrote:> Is there a cleaner way to implement an
"if not" condition check?
>if ( configfile.isFile && configfile.extension == ".conf", message
) { }
>else
if (isConfigFile(name)) {
// ...
} else {
// ...
}
The following is suitable in many
On Thursday, 18 June 2020 at 00:43:40 UTC, Stanislav Blinov wrote:
if( ! (configfile.isFile && configfile.extension == ".conf") )
?
That does indeed clean up the compound logic. One is still left
with:
if( !(
if( !
if( !(
if( !
:
I was hoping to get away from all the `not`s
On Wednesday, 17 June 2020 at 23:46:54 UTC, Denis wrote:
`if` is not a good substitute, because it works in the opposite
sense, often requiring lots of `not`s. As a trivial example:
assert( configfile.isFile && configfile.extension == ".conf" )
-vs-
if ( !configfile.isFile ||
13 matches
Mail list logo