public inbox for systemtap@sourceware.org
 help / color / mirror / Atom feed
From: fche@redhat.com (Frank Ch. Eigler)
To: Craig Ringer <craig@2ndquadrant.com>
Cc: systemtap@sourceware.org
Subject: Re: Safe-dereference operator?
Date: Tue, 18 Aug 2020 19:04:19 -0400	[thread overview]
Message-ID: <87lfibv9n0.fsf@redhat.com> (raw)
In-Reply-To: <CAMsr+YG7sYTHJ_b2ped=AK7wCJygFkqGm8xBfEXeFnGyiL90jQ@mail.gmail.com> (Craig Ringer's message of "Fri, 17 Jul 2020 11:22:32 +0800")


craig wrote:

> TL;DR: Proposal to add a safe-dereference pseudo-operator like Groovy's ?.
> to the language to simplify chasing pointer chains.
> ?. is basically an abbreviated ternary without the multiple-evaluation
> hazard:
>    a ?. b ?. c

This sounds like something that can be done via a macro
(tapset/SOMETHING.stpm) with a functional syntax, if you
can accept the multiple-evaluation problem:

@define pointer_chase_1(a,b) %( @a ? @a->@b : 0 %)
@define pointer_chase_2(a,b,c) %( @a ? (@a->@b ? @a->@b->@c : 0) : 0 %)

If you can't ... can you explain why?  Must those index
fields depend on state-modifying calculations?

- FChE


      reply	other threads:[~2020-08-18 23:04 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-07-17  3:22 Craig Ringer
2020-08-18 23:04 ` Frank Ch. Eigler [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87lfibv9n0.fsf@redhat.com \
    --to=fche@redhat.com \
    --cc=craig@2ndquadrant.com \
    --cc=systemtap@sourceware.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).