{"id":182872,"date":"2024-07-22T07:40:56","date_gmt":"2024-07-22T07:40:56","guid":{"rendered":"https:\/\/innovationspace.ansys.com\/knowledge\/?post_type=topic&#038;p=182872"},"modified":"2024-07-22T12:25:47","modified_gmt":"2024-07-22T12:25:47","slug":"scade-one-variant-types","status":"publish","type":"topic","link":"https:\/\/innovationspace.ansys.com\/knowledge\/forums\/topic\/scade-one-variant-types\/","title":{"rendered":"Scade One Variant Types"},"content":{"rendered":"<h3  id=\"INTRODUCTION\">Introduction<\/h3>\n<p>This blog entry is special: we have a video for you!<\/p>\n<p>Aubanel, our director of Ansys Customer Excellence, demonstrates a new construct in Swan, the modeling language used in Scade One, called variant types.<\/p>\n<h3  id=\"VARIANT-TYPES\">Variant types?<\/h3>\n<p>A variant type defines a data structure holding a value that can take on several different, but fixed, types. The generated C code uses union in a safe, MISRA-compatible way, by using a tag field to know which type is in use<a href=\"https:\/\/innovationspace.ansys.com\/knowledge\/wp-content\/uploads\/sites\/4\/2024\/07\/scade-017-techno-babble.gif\">.<\/a><\/p>\n<p>In short, a variant type is a type that can be <em>this or that or something else<\/em>.<\/p>\n<p>In the video, Aubanel showcases this with a <code>shape<\/code> type that can be <em>either<\/em> a rectangle, a circle or a polygon.<\/p>\n<p>This makes it easy to design generic operators that perform calculations on shapes, with no need to duplicate our logic to handle various cases for various shape types:<\/p>\n<p style=\"text-align: center;\">\n    <img decoding=\"async\" src=\"https:\/\/innovationspace.ansys.com\/knowledge\/wp-content\/uploads\/sites\/4\/2024\/07\/scade-017-variant-type-operator.png\" style=\"max-height: 500px !important;\" \/><br \/>\n    <em><\/em>\n<\/p>\n<h3  id=\"DEMO-TIME-%F0%9F%8E%AC\">Demo time \ud83c\udfac<\/h3>\n<p><iframe loading=\"lazy\" title=\"Scade One - Compute the perimeter of a shape with variant types\" width=\"640\" height=\"360\" src=\"https:\/\/www.youtube.com\/embed\/jEizl7JcvXQ?feature=oembed\" frameborder=\"0\" allow=\"accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share\" referrerpolicy=\"strict-origin-when-cross-origin\" allowfullscreen><\/iframe><\/p>\n<h3  id=\"WANT-TO-KNOW-MORE\">Want to know more?<\/h3>\n<p>In this video, you saw how variant types can power cleaner, easier-to-maintain models.<\/p>\n<p>If you&#8217;d like to find out more about Scade One, request a demo today over at <a href=\"https:\/\/www.ansys.com\/products\/embedded-software\/ansys-scade-one\">https:\/\/www.ansys.com\/products\/embedded-software\/ansys-scade-one<\/a>.<\/p>\n","protected":false},"template":"","class_list":["post-182872","topic","type-topic","status-publish","hentry","topic-tag-embedded-software","topic-tag-mbse","topic-tag-model-based-software-engineering","topic-tag-programming","topic-tag-scade-one","topic-tag-tagged-unions","topic-tag-variant-types"],"aioseo_notices":[],"acf":[],"custom_fields":[{"0":{"_edit_lock":["1722325164:181"],"_edit_last":["181"],"filter_by_optics_product":["Lumerical"],"_filter_by_optics_product":["field_64fb192ba3121"],"application_name":[""],"_application_name":["field_64a80903c8e15"],"family":[""],"_family":["field_64a809229a857"],"siebel_km_number":[""],"_siebel_km_number":["field_63ecbffce60db"],"salesforce_km_number":[""],"_salesforce_km_number":["field_63ecc018e60dc"],"km_published_date":[""],"_km_published_date":["field_64c77704499dd"],"product_version":[""],"_product_version":["field_64c776cb4fd2e"],"_bbp_forum_id":["27825"],"_bbp_topic_id":["182876"],"_bbp_author_ip":["192.104.24.227"],"_bbp_last_reply_id":["0"],"_bbp_last_active_id":["182873"],"_bbp_last_active_time":["2024-07-22 07:40:56"],"_bbp_reply_count":["0"],"_bbp_reply_count_hidden":["0"],"_bbp_voice_count":["0"],"_yoast_wpseo_estimated-reading-time-minutes":["2"],"_yoast_wpseo_wordproof_timestamp":[""],"_yoast_wpseo_content_score":["90"],"_oembed_10466edc2b39c558d8918ad5ba342f13":["<iframe title=\"Scade One - Compute the perimeter of a shape with variant types\" width=\"640\" height=\"360\" src=\"https:\/\/www.youtube.com\/embed\/jEizl7JcvXQ?feature=oembed\" frameborder=\"0\" allow=\"accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share\" referrerpolicy=\"strict-origin-when-cross-origin\" allowfullscreen><\/iframe>"],"_oembed_time_10466edc2b39c558d8918ad5ba342f13":["1721634103"],"_btv_view_count":["621"],"_wp_old_slug":["scade-one-variant-types-2"],"_bbp_likes_count":["7"]},"test":"solution"}],"_links":{"self":[{"href":"https:\/\/innovationspace.ansys.com\/knowledge\/wp-json\/wp\/v2\/topics\/182872","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/innovationspace.ansys.com\/knowledge\/wp-json\/wp\/v2\/topics"}],"about":[{"href":"https:\/\/innovationspace.ansys.com\/knowledge\/wp-json\/wp\/v2\/types\/topic"}],"version-history":[{"count":4,"href":"https:\/\/innovationspace.ansys.com\/knowledge\/wp-json\/wp\/v2\/topics\/182872\/revisions"}],"predecessor-version":[{"id":182876,"href":"https:\/\/innovationspace.ansys.com\/knowledge\/wp-json\/wp\/v2\/topics\/182872\/revisions\/182876"}],"wp:attachment":[{"href":"https:\/\/innovationspace.ansys.com\/knowledge\/wp-json\/wp\/v2\/media?parent=182872"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}