condition(3scm)
π condition(3scm) β like, the compound conditions page, bestie
okay so this is condition(3scm) from the Scheme Programmer's Manual, and it's lowkey one of the most useful little procedures in the whole condition system. we're gonna get into it, don't worry π«Ά
β¨ NAME β¨
condition β compound conditions, aka β¨the multipackβ¨ of condition objects
π LIBRARY π
bestie you gotta import it first, no cap:
(import (rnrs)) ;R6RS
(import (rnrs conditions)) ;R6RS
π©· SYNOPSIS π©·
(condition condition1 ...)
πΈ DESCRIPTION πΈ
So condition takes a bunch of conditions (yes, condition1 and friends) and returns one condition object that's made up of all their components as its components β and the order is preserved, fr fr. like, the components of condition1 show up first, in the exact same order they had inside condition1, then the components of condition2 come next, and so on down the line. it's giving "stack them in a row and don't shuffle" π
and here's the iconic part: these compound conditions act as if they were any of the simple conditions tucked inside them, as far as predicates and accessors go. so if you ask "are you an error?" or "are you a message?", the compound one is like "yeah, technically, through one of my components" π main character energy honestly.
π RETURN VALUES π
returns a single value β one condition. that returned condition is compound if the total number of components is zero or greater than one. otherwise (i.e. exactly one component, you get the vibe), it may be compound or simple. so like, don't assume, okay? π
π¦ EXAMPLES π¦
look at this beauty:
(define con
(condition
(make-error)
(make-message-condition "I am an error")))
(error? con) => #t
(message? con) => #t
(condition-message con) => "I am an error"
see?? it ate. con is both an error and a message condition at the same time, and condition-message still pulls the string right out. obsessed β
π₯ APPLICATION USAGE π₯
compound conditions are your girl when you need to describe multiple aspects of an exceptional situation. you pass them to raise(3scm) and raise-continuable(3scm), and they're normally caught with guard(7scm). that's the whole workflow, iykyk π
π COMPATIBILITY π
compound conditions are unique to R6RS. nobody else has them. exclusive club, periodt. π
π ERRORS π
this procedure can raise exceptions with the following condition types:
&assertion(R6RS) β you passed the wrong number of arguments, or an argument was outside its domain. bestie. count your args. π
π SEE ALSO π
simple-conditions(3scm)β go read that one too, it's the sibling
β STANDARDS β
R6RS π«Ά
π§ HISTORY π§
this procedure was first introduced in R6RS as part of the new condition system. so it's a glow-up baby, born fully iconic β¨
π AUTHORS π
this page is part of the scheme-manpages project β it includes materials from the RnRS documents, and more info lives at https://github.com/schemedoc/manpages/ π
ok that's the whole page, go forth and compound your conditions responsibly πΈ
and that's a wrap, bestie β brought to you by the 2022-05-14 edition of condition(3scm), mwah π
π
π¦ where this page comes from
- nixpkgs unstable: scheme-manpages 0-unstable-2024-02-11
- π the page's license: MIT
- Copyright (c) 2022 Gwen Weinholt
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms