{"id":1100,"date":"2021-03-25T07:49:00","date_gmt":"2021-03-25T13:49:00","guid":{"rendered":"https:\/\/www.great-white-software.com\/blog\/?p=1100"},"modified":"2021-03-26T08:48:05","modified_gmt":"2021-03-26T14:48:05","slug":"dim-session-as-session-session","status":"publish","type":"post","link":"https:\/\/www.great-white-software.com\/blog\/2021\/03\/25\/dim-session-as-session-session\/","title":{"rendered":"dim Session as Session = Session"},"content":{"rendered":"\n<p>Theres a long thread on the Xojo forums about <em>Color shouldnt be a reserved property name<\/em><\/p>\n\n\n\n<p>It really isnt. This is JUST the IDE preventing you from using the name IN the IDE<\/p>\n\n\n\n<p>It causes no confusion.<\/p>\n\n\n\n<p>The title of this article was, at one time, a recommended way for figuring out the current session in a Web 1.0 app<\/p>\n\n\n\n<p>The compiler has NO issue sorting out whats a variable, whats a data type, and whats a method call.<\/p>\n\n\n\n<p>In the code from the  title it knows that :<\/p>\n\n\n\n<ol class=\"wp-block-list\"><li>the first <em>session<\/em> following the dim MUST be a variable name (it cannot be a method call, property, constant or data type in that position)<\/li><li>the second dim following the AS MUST be a datatype. It cannot be a variable name or method call, or property or constant etc<\/li><li>and the last session, following the =, cannot be a data type. So it MUST be either another variable name OR method call. Since this line is just not defining this variable it cant be a usage of itself and that leaves ONLY a method as a possibility.<\/li><\/ol>\n\n\n\n<p>The compiler gets it right.<\/p>\n\n\n\n<p>And you can see that it does if you :<\/p>\n\n\n\n<ul class=\"wp-block-list\"><li>start a new desktop project<\/li><li>add a new class and name it Foo<\/li><li>add a shared method to Window1, named foo() that returns foo<\/li><li>now add a property to Window1 named foo as foo<\/li><li>the in Window1.Open simply put this one line of code<\/li><\/ul>\n\n\n\n<pre class=\"wp-block-code\"><code>self.foo = Foo<\/code><\/pre>\n\n\n\n<p><em>self.foo<\/em> refers, int this case, to the PROPERTY (since there is no method that could possible be called &#8211; there is not assigns version that might cause ambiguity)<\/p>\n\n\n\n<p>The <em>Foo<\/em> after the = has to be either a variable or method; Xojo&#8217;s preference is to call the method before trying to use a property<\/p>\n\n\n\n<p>Now, would I recommend using the name of an existing data type as a property ? In general no but there are cases where it makes perfect sense.<\/p>\n\n\n\n<p>Suppose to have a class that represents a run of text that all has the same type. Its a consistent type face, size, italic, bold etc and one of those properties on such a thing could reasonably be &#8220;Color&#8221;.<\/p>\n\n\n\n<p>Many have suggested calling it something else for clarity. But that might actually BE the most accurate name for it. For instance Xojo itself has <a href=\"http:\/\/docs.xojo.com\/StyleRun\">such a data type<\/a> but they use the name &#8220;textcolor&#8221;. Color would actually be a suitable name here.<\/p>\n\n\n\n<p><a href=\"http:\/\/great-white-software.com\/miscellaneous\/PropertyWithDataTypeName.xojo_binary_project\">Here&#8217;s a sample project<\/a> that does exactly this and has NO issue<br><br>EDIT : You can even write as one line in 2020r2.1<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>dim color as Color = Color.RGB(230,198, 178)<\/code><\/pre>\n\n\n\n<p>No confusion arises compiling this line (there may be ancillary issues with other code but COLOR isn&#8217;t &#8220;reserved&#8221; to ONLY be a data type name.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Theres a long thread on the Xojo forums about Color shouldnt be a reserved property name It really isnt. This is JUST the IDE preventing you from using the name IN the IDE It causes no confusion. The title of this article was, at one time, a recommended way for figuring out the current session &hellip; <\/p>\n<p class=\"link-more\"><a href=\"https:\/\/www.great-white-software.com\/blog\/2021\/03\/25\/dim-session-as-session-session\/\" class=\"more-link\">Continue reading<span class=\"screen-reader-text\"> &#8220;dim Session as Session = Session&#8221;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_jetpack_memberships_contains_paid_content":false,"footnotes":""},"categories":[1],"tags":[],"class_list":["post-1100","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"jetpack_featured_media_url":"","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/www.great-white-software.com\/blog\/wp-json\/wp\/v2\/posts\/1100","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.great-white-software.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.great-white-software.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.great-white-software.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.great-white-software.com\/blog\/wp-json\/wp\/v2\/comments?post=1100"}],"version-history":[{"count":4,"href":"https:\/\/www.great-white-software.com\/blog\/wp-json\/wp\/v2\/posts\/1100\/revisions"}],"predecessor-version":[{"id":1115,"href":"https:\/\/www.great-white-software.com\/blog\/wp-json\/wp\/v2\/posts\/1100\/revisions\/1115"}],"wp:attachment":[{"href":"https:\/\/www.great-white-software.com\/blog\/wp-json\/wp\/v2\/media?parent=1100"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.great-white-software.com\/blog\/wp-json\/wp\/v2\/categories?post=1100"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.great-white-software.com\/blog\/wp-json\/wp\/v2\/tags?post=1100"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}