Re: Designing sruby (Secure Ruby) - Use ivars (@balance) or Storage class (storage.balance) for (Blockchain) State?
Gerald Bauer <[email protected]>
| Newsgroups | gmane.comp.lang.ruby.general |
|---|---|
| Message-ID | <CAAxEZd9KcC+uLXZzU3qN1vBtc0hqwewV4_hoeGRAR76a0Zoi2A@mail.gmail.com> |
Hello,
FYI: I've decided to have it both ways - and follow the ruby (and
perl) tradition of There's more than one way to do it :-).
How? The code gets "auto-patched" with a regex [1] on load and
changes the "short" form to the long from using a storage class.
Happy coding with ruby (and sruby). Cheers. Prost.
[1] code = code.gsub( /(@{1,})([a-z][a-zA-Z0-9_]*)/ ) do |_|
if $1.size == 1
puts "auto-patching contract code >#{$1}#{$2}< to
>storage[ :#{$2} ]<"
"storage[ :#{$2} ]"
else
## assume class variable - skip - keep as is
"#{$1}#{$2}"
end
end
Unsubscribe: <mailto:[email protected]?subject=unsubscribe>
<http://lists.ruby-lang.org/cgi-bin/mailman/options/ruby-talk>