@aerilius said:
Looks good so far. I haven't seen anyone using ² in a module name (but if it works, though Unicode characters like ᚠᚢᚦᚨᚱᚲ are not supported in our version of Ruby in SketchUp, otherwise my plugins would be full of them).
² also exists in the ANSI set - so I could be a simple one byte character is he used that encoding.
@aerilius said:
Looks good so far. I haven't seen anyone using ² in a module name (but if it works, though Unicode characters like ᚠᚢᚦᚨᚱᚲ are not supported in our version of Ruby in SketchUp, otherwise my plugins would be full of them).
I copied the example from this page: http://www.oreillynet.com/ruby/blog/2007/10/fun_with_unicode_1.html
<span class="syntaxdefault"><br />module Kernel<br /> alias λ proc<br /><br /> def ∑</span><span class="syntaxkeyword">(*</span><span class="syntaxdefault">args</span><span class="syntaxkeyword">)<br /> </span><span class="syntaxdefault">sum </span><span class="syntaxkeyword">= </span><span class="syntaxdefault">0<br /> args</span><span class="syntaxkeyword">.</span><span class="syntaxdefault">each</span><span class="syntaxkeyword">{ |</span><span class="syntaxdefault">e</span><span class="syntaxkeyword">| </span><span class="syntaxdefault">sum </span><span class="syntaxkeyword">+= </span><span class="syntaxdefault">e </span><span class="syntaxkeyword">}<br /> </span><span class="syntaxdefault">sum<br /> end<br /><br /> def √</span><span class="syntaxkeyword">(</span><span class="syntaxdefault">root</span><span class="syntaxkeyword">)<br /> </span><span class="syntaxdefault">Math</span><span class="syntaxkeyword">.</span><span class="syntaxdefault">sqrt</span><span class="syntaxkeyword">(</span><span class="syntaxdefault">root</span><span class="syntaxkeyword">)<br /> </span><span class="syntaxdefault">end<br />end<br /></span>
And it worked:
` # A real lambda
λ { puts ‘Hello’ }.call => ‘Hello’
Sigma - sum of all elements
∑(1,2,3) => 6
Square root
√ 49 => 7.0`
You can also do this:
<span class="syntaxdefault"><br />module MyTest<br /> def self</span><span class="syntaxkeyword">.</span><span class="syntaxdefault">ᚠᚢᚦᚨᚱᚲ<br /> puts </span><span class="syntaxstring">'world'<br /> </span><span class="syntaxdefault">end<br />end<br /></span>
But not this:
<span class="syntaxdefault"><br />module ᚠᚢᚦᚨᚱᚲ<br /> def self</span><span class="syntaxkeyword">.</span><span class="syntaxdefault">hello<br /> puts </span><span class="syntaxstring">'world'<br /> </span><span class="syntaxdefault">end<br />end<br /></span>
Return an error:
Error: #<SyntaxError: (eval):516: compile error (eval):516: class/module name must be CONSTANT module ᚠᚢᚦᚨᚱᚲ; def self.hello; puts 'world'; end; end ^> (eval):516
That seem to be related to ᚠ not being recognised as a capital letter.
Because this works:
<span class="syntaxdefault"><br />module Xᚠᚢᚦᚨᚱᚲ</span><span class="syntaxkeyword">; </span><span class="syntaxdefault">end<br /></span>