RAD type hints

2 views
Skip to first unread message

Sophie

unread,
Jan 17, 2010, 8:19:26 PM1/17/10
to ruby-arduino...@googlegroups.com
How do I type-hint to get a Ruby function
def show(s)
...
end

to become something close to
void show(const char* s) { ... }

By default it becomes:
void show(void* s)

I tried
def show(s)
"" + s  ## or  s + ""
...
end

With no success. 

Should I be avoiding passing params around? 

Thanks!

xraid

unread,
Jan 22, 2010, 9:01:42 AM1/22/10
to Ruby Arduino Development
try a @s = "c" and use in def show(@s) . as a hinting to the
translator ...

Sophie

unread,
Jan 22, 2010, 3:16:42 PM1/22/10
to ruby-arduino...@googlegroups.com
Tried it, but def show(@s) won't compile as it sees @s as instance
variable.

> --
> You received this message because you are subscribed to the Google
> Groups "Ruby Arduino Development" group.
> To post to this group, send email to ruby-arduino...@googlegroups.com
> .
> To unsubscribe from this group, send email to ruby-arduino-devel...@googlegroups.com
> .
> For more options, visit this group at http://groups.google.com/group/ruby-arduino-development?hl=en
> .
>
>

xraid

unread,
Jan 23, 2010, 8:06:14 AM1/23/10
to Ruby Arduino Development
i declare a
@s = 'c'
gets to a
char* __s = "c"; in .cpp

use that in def show <do whatever with @s> end

is it the programming style you are after ?

Sophie

unread,
Jan 23, 2010, 10:03:17 PM1/23/10
to ruby-arduino...@googlegroups.com
Not quite, though it is good to know it will work as a backup.

I was hoping to get the method input parameter to type as a char*,
rather than use @instance / global variables for all information
passing.

- Sophie

Reply all
Reply to author
Forward
0 new messages