# Value types - e.g. TimeSpan

**URL:** <https://www.ruby-forum.com/t/value-types-e-g-timespan/201677>\
**Category:** IronRuby\
**Created:** [January 12, 2011, 7:30pm UTC](https://www.ruby-forum.com/t/value-types-e-g-timespan/201677 "2011-01-12T19:30:41Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![luislavena](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/l/0ea827/32.png) [@luislavena](https://www.ruby-forum.com/u/luislavena)\
**Post date:** [January 12, 2011, 7:30pm UTC](https://www.ruby-forum.com/t/value-types-e-g-timespan/201677/1 "2011-01-12T19:30:41Z")

</div>

Hi all

I’ve had some discussions offline about accessing the properties of  
TimeSpan.

The issue is that while the static methods on TimeSpan work, the  
instance  
properties don’t:

t = System::TimeSpan.from\_seconds(1.1) # works  
m = t.total\_milliseconds # doesn’t work

All my testing done on iron7 on WP7 of course!

The route of this problem seems to be (from Tomas M.):

The problem is that the interpreter doesn’t support instance method  
calls on

> value types:

> if (!node.Method.IsStatic && node.Method.DeclaringType.IsValueType &&  
> !node.Method.DeclaringType.IsPrimitive)) \_forceCompile = true;

> Such method can update the value type in-place, which is difficult to  
> interpret. We don’t know that the method is only reading the fields of the  
> value type, so we disallow interpretation even if we could do that. I’ll  
> think about how to fix this but am not sure if we can do anything  
> reasonable.

We’re thinking about this… one thing is that I think we could allow  
this  
for Get methods - for readonly properties - I need to read the code a  
bit (a  
lot!) more before I can comment on whether this is correct though…

Stuart

---

<div class="post-metadata">

**Author:** ![evildrummer](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/e/f05b48/32.png) [@evildrummer](https://www.ruby-forum.com/u/evildrummer)\
**Post date:** [January 12, 2011, 8:14pm UTC](https://www.ruby-forum.com/t/value-types-e-g-timespan/201677/2 "2011-01-12T20:14:41Z")

</div>

You could probably allow methods as well, as the vast majority of value  
types are immutable. Even in C#, calling Set on a value type only works  
if  
that value type happens to be a local variable. If it comes back from a  
property then it just becomes a no-op.

Jonathan
