View Issue Details
ID | Project | Category | View Status | Date Submitted | Last Update |
---|---|---|---|---|---|
0000646 | LDMud 3.3 | LPC Language | public | 2009-06-01 04:22 | 2010-01-24 12:03 |
Reporter | _xtian_ | Assigned To | zesstra | ||
Priority | normal | Severity | feature | Reproducibility | have not tried |
Status | resolved | Resolution | fixed | ||
Product Version | 3.3.717 | ||||
Target Version | 3.3.720 | Fixed in Version | 3.3.720 | ||
Summary | 0000646: to_struct( STRUCT ) does nothing but could cast to other template | ||||
Description | Since casting in LPC is mostly done by to_int(), to_string(), etc ... it would be useful to be able to cast a struct to another struct type by using to_struct(). to_struct() already can cast mappings to specific struct-type by giving: to_struct( MAPPING, STRUCT-TEMPLATE ) so this would be a similar functionality. I propose: to_struct( STRUCT, STRUCT-TEMPLATE ) Strictly speaking this can already be done by: to_struct( mkmapping( STRUCT ), STRUCT-TEMPLATE ) but I would suggest that this form of re-casting a struct should be stricter and thus throw an error/warning on incompatible struct-types (for ex. which are not inherited from another). | ||||
Tags | No tags attached. | ||||
related to | 0000645 | new | casting structs (to 'inherited struct') does nothing |
|
Mhmm, I am not sure, if there is any information about the relation of two structs (e.g. b 'inherited' a) at runtime. |
|
Oh. hm. Mist. ;) |
|
There is even an efun that can do it: baseof. (But it seems that is has problems with empty base structs.) |
|
I like the idea (although I would not call it 'cast', but 'conversion'). We could discuss, if in addition to conversion between structs in the same 'struct-inherit-chain' the conversion from anonymous structs to a specific one should be possible. And one question is, if you can only convert from an inherited struct to one which inherits or also in the other direction: struct a_s {int i;}; struct b_s (a_s) {int j; }; Conversion from a_s to b_s is simple (b_s->j would remain 0). Conversion from b_s to a_s: disallow or just discard b_s->j in the new instance of a_s? |
|
Yes, I have a use-case where I convert up. Although the 'parent-struct' doesn't add members (I use it as a sort of typedef). |
|
I created a patch for 3.5 implementing the conversion from a base to one its children and from a child to one of its bases. This is r2794 in trunk. I plan to apply that later together with some other changes (e.g. for 0000695) to 3.3. |
|
So far I heard of no complaints. I applied the changes as well to the 3.3 branch (r2827 - r2832). This should conclude the issue for now. |
Date Modified | Username | Field | Change |
---|---|---|---|
2009-06-01 04:22 | _xtian_ | New Issue | |
2009-06-01 05:37 | zesstra | Project | LDMud => LDMud 3.5 |
2009-06-01 06:05 | zesstra | Note Added: 0001176 | |
2009-06-01 06:07 | _xtian_ | Note Added: 0001177 | |
2009-06-01 07:01 | Gnomi | Note Added: 0001181 | |
2009-10-27 09:21 | zesstra | Note Added: 0001562 | |
2009-10-27 12:49 | _xtian_ | Note Added: 0001565 | |
2009-11-03 15:35 | zesstra | Status | new => assigned |
2009-11-03 15:35 | zesstra | Assigned To | => zesstra |
2009-11-03 15:38 | zesstra | Note Added: 0001591 | |
2009-11-03 15:38 | zesstra | Project | LDMud 3.5 => LDMud 3.3 |
2009-11-03 15:39 | zesstra | Target Version | => 3.3.720 |
2009-11-05 14:08 | zesstra | Relationship added | related to 0000645 |
2010-01-24 12:03 | zesstra | Note Added: 0001696 | |
2010-01-24 12:03 | zesstra | Status | assigned => resolved |
2010-01-24 12:03 | zesstra | Fixed in Version | => 3.3.720 |
2010-01-24 12:03 | zesstra | Resolution | open => fixed |