News for hackers. Stuff that matters.
Re:A Defer Mechanism for C by yvdriess on Monday December 14, 2020 @09:48AM (#25418145)
guard/defer is semantically and syntactically as explicit (or implicit) as C's automatic storage class (https://en.cppreference.com/w/c/language/storage_duration), which is the default storage class.
Re:A Defer Mechanism for C by fanf2 on Monday December 14, 2020 @10:18AM (#25418488)
Only if you include dynamically sized arrays, which are deprecated because of their problematic allocation behaviour.
Re:A Defer Mechanism for C by shakna on Monday December 14, 2020 @10:43AM (#25418794)
I don't believe that VLAs are actually deprecated as such, but have been moved to an "optional" feature for implementation in C11. There's a feature macro to check, __STDC_NO_VLA__, but I don't think the feature is actually disappearing from the standard any time soon.
Re:A Defer Mechanism for C by cassepipe on Monday December 14, 2020 @03:57PM (#25423184)
I wonder what is a good use for VLAs btw. I used it for a string padding function to create the padding with a simple loop before a call to strjoin. Is that a bad idea or a legitimate use case?
Re:A Defer Mechanism for C by saagarjha on Monday December 14, 2020 @07:59PM (#25425689)
Don't use VLAs for anything that actually requires an allocation. However, VLAs are quite useful when you have a buffer and want to access it like an array.