Re: [Development] Go's "defer" statement for C++/Qt
> On 8 Mar 2019, at 06:47, Timur Pocheptsov wrote: > > Tor Arne +2! To be clear, qScopedGuard was contributed by Sérgio Martins Sérgio Martins++ Tor Arne ___ Development mailing list Development@qt-project.org https://lists.qt-project.org/listinfo/development
Re: [Development] Go's "defer" statement for C++/Qt
I took the liberty of fixing this as I found something else in the doc that was wrong too so figured it was quicker to go and do it instead of mentioning it ( https://codereview.qt-project.org/255289 to avoid any duplicates of people doing it already. Andy -Opprinnelig melding- Fra: Development på vegne av Timur Pocheptsov Dato: fredag 8. mars 2019 06:49 Til: Jason H , Tor Arne Vestbø Kopi: "development@qt-project.org" Emne: Re: [Development] Go's "defer" statement for C++/Qt Tor Arne +2! :D From: Development [development-boun...@qt-project.org] on behalf of Jason H [jh...@gmx.com] Sent: Thursday, March 7, 2019 11:59 PM To: Tor Arne Vestbø Cc: Qt development mailing list Subject: Re: [Development] Go's "defer" statement for C++/Qt The verbiage in the example is wrong: code_that_might_through_exceptions(); should be: code_that_might_throw_exceptions(); Took me a moment to figure out just what it meant. > Sent: Thursday, March 07, 2019 at 12:09 PM > From: "Tor Arne Vestbø" > To: "Volker Hilsheimer" > Cc: "Qt development mailing list" > Subject: Re: [Development] Go's "defer" statement for C++/Qt > > https://doc.qt.io/qt-5/qscopeguard.html > > Tor Arne > > > On 7 Mar 2019, at 18:01, Volker Hilsheimer wrote: > > > > Ahoy, > > > > In what little development I’ve done in golang, I appreciated the “defer” statement as a means to write cleaner code. Basically, defer schedules a statement for execution when the stack unwinds. > > > > https://tour.golang.org/flowcontrol/12 > > > > We have several specialized helper classes in Qt for similar purposes, f.ex QMutexLocker and friends, or the internal QBoolBlocker [1]. Seeing the various specialized classes we have, I thought that something generic in Qt could be useful to have (although our specialised classes provide some additional convenience and/or logic). > > > > So, I pushed a few lines code to > > > > https://git.qt.io/vohilshe/qt_defer > > > > Would like to hear what you think. > > > > Perhaps someone can find ways to make this more elegant without introducing tons of preprocessor/macro shenanigans, or perhaps even without depending on C++17's implicit template argument deduction (without enabling C++17 in the config this doesn't build for me, even though I don’t use auto in the template paramter list). > > > > > > Cheers, > > Volker > > > > > > [1] which was requested to be made public in https://bugreports.qt.io/browse/QTBUG-38575 > > > > > > ___ > > Development mailing list > > Development@qt-project.org > > https://lists.qt-project.org/listinfo/development > > ___ > Development mailing list > Development@qt-project.org > https://lists.qt-project.org/listinfo/development > ___ Development mailing list Development@qt-project.org https://lists.qt-project.org/listinfo/development ___ Development mailing list Development@qt-project.org https://lists.qt-project.org/listinfo/development ___ Development mailing list Development@qt-project.org https://lists.qt-project.org/listinfo/development
Re: [Development] Go's "defer" statement for C++/Qt
Tor Arne +2! :D From: Development [development-boun...@qt-project.org] on behalf of Jason H [jh...@gmx.com] Sent: Thursday, March 7, 2019 11:59 PM To: Tor Arne Vestbø Cc: Qt development mailing list Subject: Re: [Development] Go's "defer" statement for C++/Qt The verbiage in the example is wrong: code_that_might_through_exceptions(); should be: code_that_might_throw_exceptions(); Took me a moment to figure out just what it meant. > Sent: Thursday, March 07, 2019 at 12:09 PM > From: "Tor Arne Vestbø" > To: "Volker Hilsheimer" > Cc: "Qt development mailing list" > Subject: Re: [Development] Go's "defer" statement for C++/Qt > > https://doc.qt.io/qt-5/qscopeguard.html > > Tor Arne > > > On 7 Mar 2019, at 18:01, Volker Hilsheimer wrote: > > > > Ahoy, > > > > In what little development I’ve done in golang, I appreciated the “defer” > > statement as a means to write cleaner code. Basically, defer schedules a > > statement for execution when the stack unwinds. > > > > https://tour.golang.org/flowcontrol/12 > > > > We have several specialized helper classes in Qt for similar purposes, f.ex > > QMutexLocker and friends, or the internal QBoolBlocker [1]. Seeing the > > various specialized classes we have, I thought that something generic in Qt > > could be useful to have (although our specialised classes provide some > > additional convenience and/or logic). > > > > So, I pushed a few lines code to > > > > https://git.qt.io/vohilshe/qt_defer > > > > Would like to hear what you think. > > > > Perhaps someone can find ways to make this more elegant without introducing > > tons of preprocessor/macro shenanigans, or perhaps even without depending > > on C++17's implicit template argument deduction (without enabling C++17 in > > the config this doesn't build for me, even though I don’t use auto in the > > template paramter list). > > > > > > Cheers, > > Volker > > > > > > [1] which was requested to be made public in > > https://bugreports.qt.io/browse/QTBUG-38575 > > > > > > ___ > > Development mailing list > > Development@qt-project.org > > https://lists.qt-project.org/listinfo/development > > ___ > Development mailing list > Development@qt-project.org > https://lists.qt-project.org/listinfo/development > ___ Development mailing list Development@qt-project.org https://lists.qt-project.org/listinfo/development ___ Development mailing list Development@qt-project.org https://lists.qt-project.org/listinfo/development
Re: [Development] Go's "defer" statement for C++/Qt
The verbiage in the example is wrong: code_that_might_through_exceptions(); should be: code_that_might_throw_exceptions(); Took me a moment to figure out just what it meant. > Sent: Thursday, March 07, 2019 at 12:09 PM > From: "Tor Arne Vestbø" > To: "Volker Hilsheimer" > Cc: "Qt development mailing list" > Subject: Re: [Development] Go's "defer" statement for C++/Qt > > https://doc.qt.io/qt-5/qscopeguard.html > > Tor Arne > > > On 7 Mar 2019, at 18:01, Volker Hilsheimer wrote: > > > > Ahoy, > > > > In what little development I’ve done in golang, I appreciated the “defer” > > statement as a means to write cleaner code. Basically, defer schedules a > > statement for execution when the stack unwinds. > > > > https://tour.golang.org/flowcontrol/12 > > > > We have several specialized helper classes in Qt for similar purposes, f.ex > > QMutexLocker and friends, or the internal QBoolBlocker [1]. Seeing the > > various specialized classes we have, I thought that something generic in Qt > > could be useful to have (although our specialised classes provide some > > additional convenience and/or logic). > > > > So, I pushed a few lines code to > > > > https://git.qt.io/vohilshe/qt_defer > > > > Would like to hear what you think. > > > > Perhaps someone can find ways to make this more elegant without introducing > > tons of preprocessor/macro shenanigans, or perhaps even without depending > > on C++17's implicit template argument deduction (without enabling C++17 in > > the config this doesn't build for me, even though I don’t use auto in the > > template paramter list). > > > > > > Cheers, > > Volker > > > > > > [1] which was requested to be made public in > > https://bugreports.qt.io/browse/QTBUG-38575 > > > > > > ___ > > Development mailing list > > Development@qt-project.org > > https://lists.qt-project.org/listinfo/development > > ___ > Development mailing list > Development@qt-project.org > https://lists.qt-project.org/listinfo/development > ___ Development mailing list Development@qt-project.org https://lists.qt-project.org/listinfo/development
Re: [Development] Go's "defer" statement for C++/Qt
Hey Alexander, deferred signal emission (or rather, deferred slot invocation) is a different topic. Wouldn't work well in my example, for the lack of an event loop. And object lifetime management would either way be a mess. Suggest you check the link to the explanation of go that I included Cheers, Volker From: Alexander Akulich Sent: Thursday, March 7, 2019 6:24 PM To: Volker Hilsheimer Cc: Qt development mailing list Subject: Re: [Development] Go's "defer" statement for C++/Qt Hi Volker, I have no idea about Go, but deferred signal emission is somewhat useful in async programming (at least in my practice). In that case, there is a need to 'defer' execution to continue after the control is returned (usually in EventLoop via QMetaObject::invokeMethod(..., Qt::QueuedConnection). A cleaner approach would be appreciated. On Thu, Mar 7, 2019 at 8:02 PM Volker Hilsheimer wrote: > > Ahoy, > > In what little development I’ve done in golang, I appreciated the “defer” > statement as a means to write cleaner code. Basically, defer schedules a > statement for execution when the stack unwinds. > > https://tour.golang.org/flowcontrol/12 > > We have several specialized helper classes in Qt for similar purposes, f.ex > QMutexLocker and friends, or the internal QBoolBlocker [1]. Seeing the > various specialized classes we have, I thought that something generic in Qt > could be useful to have (although our specialised classes provide some > additional convenience and/or logic). > > So, I pushed a few lines code to > > https://git.qt.io/vohilshe/qt_defer > > Would like to hear what you think. > > Perhaps someone can find ways to make this more elegant without introducing > tons of preprocessor/macro shenanigans, or perhaps even without depending on > C++17's implicit template argument deduction (without enabling C++17 in the > config this doesn't build for me, even though I don’t use auto in the > template paramter list). > > > Cheers, > Volker > > > [1] which was requested to be made public in > https://bugreports.qt.io/browse/QTBUG-38575 > > > ___ > Development mailing list > Development@qt-project.org > https://lists.qt-project.org/listinfo/development ___ Development mailing list Development@qt-project.org https://lists.qt-project.org/listinfo/development
Re: [Development] Go's "defer" statement for C++/Qt
Hi Volker, I have no idea about Go, but deferred signal emission is somewhat useful in async programming (at least in my practice). In that case, there is a need to 'defer' execution to continue after the control is returned (usually in EventLoop via QMetaObject::invokeMethod(..., Qt::QueuedConnection). A cleaner approach would be appreciated. On Thu, Mar 7, 2019 at 8:02 PM Volker Hilsheimer wrote: > > Ahoy, > > In what little development I’ve done in golang, I appreciated the “defer” > statement as a means to write cleaner code. Basically, defer schedules a > statement for execution when the stack unwinds. > > https://tour.golang.org/flowcontrol/12 > > We have several specialized helper classes in Qt for similar purposes, f.ex > QMutexLocker and friends, or the internal QBoolBlocker [1]. Seeing the > various specialized classes we have, I thought that something generic in Qt > could be useful to have (although our specialised classes provide some > additional convenience and/or logic). > > So, I pushed a few lines code to > > https://git.qt.io/vohilshe/qt_defer > > Would like to hear what you think. > > Perhaps someone can find ways to make this more elegant without introducing > tons of preprocessor/macro shenanigans, or perhaps even without depending on > C++17's implicit template argument deduction (without enabling C++17 in the > config this doesn't build for me, even though I don’t use auto in the > template paramter list). > > > Cheers, > Volker > > > [1] which was requested to be made public in > https://bugreports.qt.io/browse/QTBUG-38575 > > > ___ > Development mailing list > Development@qt-project.org > https://lists.qt-project.org/listinfo/development ___ Development mailing list Development@qt-project.org https://lists.qt-project.org/listinfo/development
Re: [Development] Go's "defer" statement for C++/Qt
Le jeu. 7 mars 2019 à 18:09, Tor Arne Vestbø a écrit : > > https://doc.qt.io/qt-5/qscopeguard.html > Nice ! And apparently there is also https://doc.qt.io/qt-5/qscopedvaluerollback.html, which seems to be a public and templatized version of QBoolBlocker. > Tor Arne > > > On 7 Mar 2019, at 18:01, Volker Hilsheimer wrote: > > > > Ahoy, > > > > In what little development I’ve done in golang, I appreciated the “defer” > > statement as a means to write cleaner code. Basically, defer schedules a > > statement for execution when the stack unwinds. > > > > https://tour.golang.org/flowcontrol/12 > > > > We have several specialized helper classes in Qt for similar purposes, f.ex > > QMutexLocker and friends, or the internal QBoolBlocker [1]. Seeing the > > various specialized classes we have, I thought that something generic in Qt > > could be useful to have (although our specialised classes provide some > > additional convenience and/or logic). > > > > So, I pushed a few lines code to > > > > https://git.qt.io/vohilshe/qt_defer > > > > Would like to hear what you think. > > > > Perhaps someone can find ways to make this more elegant without introducing > > tons of preprocessor/macro shenanigans, or perhaps even without depending > > on C++17's implicit template argument deduction (without enabling C++17 in > > the config this doesn't build for me, even though I don’t use auto in the > > template paramter list). > > > > > > Cheers, > > Volker > > > > > > [1] which was requested to be made public in > > https://bugreports.qt.io/browse/QTBUG-38575 Julien Cugnière ___ Development mailing list Development@qt-project.org https://lists.qt-project.org/listinfo/development
Re: [Development] Go's "defer" statement for C++/Qt
std::async(std::launch::deferred, ...); ? Best regards, Jesús Original message From: Tor Arne Vestbø Date: 07/03/2019 18:11 (GMT+01:00) To: Volker Hilsheimer Cc: Qt development mailing list Subject: Re: [Development] Go's "defer" statement for C++/Qt https://doc.qt.io/qt-5/qscopeguard.html Tor Arne > On 7 Mar 2019, at 18:01, Volker Hilsheimer wrote: > > Ahoy, > > In what little development I’ve done in golang, I appreciated the “defer” > statement as a means to write cleaner code. Basically, defer schedules a > statement for execution when the stack unwinds. > > https://tour.golang.org/flowcontrol/12 > > We have several specialized helper classes in Qt for similar purposes, f.ex > QMutexLocker and friends, or the internal QBoolBlocker [1]. Seeing the > various specialized classes we have, I thought that something generic in Qt > could be useful to have (although our specialised classes provide some > additional convenience and/or logic). > > So, I pushed a few lines code to > > https://git.qt.io/vohilshe/qt_defer > > Would like to hear what you think. > > Perhaps someone can find ways to make this more elegant without introducing > tons of preprocessor/macro shenanigans, or perhaps even without depending on > C++17's implicit template argument deduction (without enabling C++17 in the > config this doesn't build for me, even though I don’t use auto in the > template paramter list). > > > Cheers, > Volker > > > [1] which was requested to be made public in > https://bugreports.qt.io/browse/QTBUG-38575 > > > ___ > Development mailing list > Development@qt-project.org > https://lists.qt-project.org/listinfo/development ___ Development mailing list Development@qt-project.org https://lists.qt-project.org/listinfo/development ___ Development mailing list Development@qt-project.org https://lists.qt-project.org/listinfo/development
Re: [Development] Go's "defer" statement for C++/Qt
oh... it's already in qt. I've been doing it with my own class all this time. On Thu, Mar 7, 2019 at 8:10 PM Tor Arne Vestbø wrote: > https://doc.qt.io/qt-5/qscopeguard.html > > Tor Arne > > > On 7 Mar 2019, at 18:01, Volker Hilsheimer > wrote: > > > > Ahoy, > > > > In what little development I’ve done in golang, I appreciated the > “defer” statement as a means to write cleaner code. Basically, defer > schedules a statement for execution when the stack unwinds. > > > > https://tour.golang.org/flowcontrol/12 > > > > We have several specialized helper classes in Qt for similar purposes, > f.ex QMutexLocker and friends, or the internal QBoolBlocker [1]. Seeing the > various specialized classes we have, I thought that something generic in Qt > could be useful to have (although our specialised classes provide some > additional convenience and/or logic). > > > > So, I pushed a few lines code to > > > > https://git.qt.io/vohilshe/qt_defer > > > > Would like to hear what you think. > > > > Perhaps someone can find ways to make this more elegant without > introducing tons of preprocessor/macro shenanigans, or perhaps even without > depending on C++17's implicit template argument deduction (without enabling > C++17 in the config this doesn't build for me, even though I don’t use auto > in the template paramter list). > > > > > > Cheers, > > Volker > > > > > > [1] which was requested to be made public in > https://bugreports.qt.io/browse/QTBUG-38575 > > > > > > ___ > > Development mailing list > > Development@qt-project.org > > https://lists.qt-project.org/listinfo/development > > ___ > Development mailing list > Development@qt-project.org > https://lists.qt-project.org/listinfo/development > ___ Development mailing list Development@qt-project.org https://lists.qt-project.org/listinfo/development
Re: [Development] Go's "defer" statement for C++/Qt
https://doc.qt.io/qt-5/qscopeguard.html Tor Arne > On 7 Mar 2019, at 18:01, Volker Hilsheimer wrote: > > Ahoy, > > In what little development I’ve done in golang, I appreciated the “defer” > statement as a means to write cleaner code. Basically, defer schedules a > statement for execution when the stack unwinds. > > https://tour.golang.org/flowcontrol/12 > > We have several specialized helper classes in Qt for similar purposes, f.ex > QMutexLocker and friends, or the internal QBoolBlocker [1]. Seeing the > various specialized classes we have, I thought that something generic in Qt > could be useful to have (although our specialised classes provide some > additional convenience and/or logic). > > So, I pushed a few lines code to > > https://git.qt.io/vohilshe/qt_defer > > Would like to hear what you think. > > Perhaps someone can find ways to make this more elegant without introducing > tons of preprocessor/macro shenanigans, or perhaps even without depending on > C++17's implicit template argument deduction (without enabling C++17 in the > config this doesn't build for me, even though I don’t use auto in the > template paramter list). > > > Cheers, > Volker > > > [1] which was requested to be made public in > https://bugreports.qt.io/browse/QTBUG-38575 > > > ___ > Development mailing list > Development@qt-project.org > https://lists.qt-project.org/listinfo/development ___ Development mailing list Development@qt-project.org https://lists.qt-project.org/listinfo/development
[Development] Go's "defer" statement for C++/Qt
Ahoy, In what little development I’ve done in golang, I appreciated the “defer” statement as a means to write cleaner code. Basically, defer schedules a statement for execution when the stack unwinds. https://tour.golang.org/flowcontrol/12 We have several specialized helper classes in Qt for similar purposes, f.ex QMutexLocker and friends, or the internal QBoolBlocker [1]. Seeing the various specialized classes we have, I thought that something generic in Qt could be useful to have (although our specialised classes provide some additional convenience and/or logic). So, I pushed a few lines code to https://git.qt.io/vohilshe/qt_defer Would like to hear what you think. Perhaps someone can find ways to make this more elegant without introducing tons of preprocessor/macro shenanigans, or perhaps even without depending on C++17's implicit template argument deduction (without enabling C++17 in the config this doesn't build for me, even though I don’t use auto in the template paramter list). Cheers, Volker [1] which was requested to be made public in https://bugreports.qt.io/browse/QTBUG-38575 ___ Development mailing list Development@qt-project.org https://lists.qt-project.org/listinfo/development