var/list/List = list(new/obj/Test)
obj/Test
proc/Check()
return TRUE
proc
Testing()
if(List[1]:Check())
world<<"This works!"
ID:1313313
Jul 3 2013, 11:41 pm (Edited on Jun 30 2014, 2:35 pm)
|
|||||||
Resolved
| |||||||
The ability to call a proc directly from a object from within a list.
|
In response to Neimo
|
|
Neimo wrote:
Without having to use call :p if I wanted to do that I would. |
for(var/obj/Test in List) or var/obj/Test/listobj = List[1] |
You'd never be able to do this with the . - the strict deference operator.
You'd have to use : - the lax dereference operator. |
In response to Super Saiyan X
|
|
Super Saiyan X wrote:
You'd never be able to do this with the . - the strict deference operator. Oops seemed to overlook that. |
Because : or a type cast into a variable permits the same thing, without muddying the language semantics further.
. operator is specifically a direct reference operation, it uses the type information on the given variable at compile-time to enforce if a given reference is okay to make. The list presents no compile-time information on it's contents, so there's no guarantee the compiler can make, AKA the operation makes no sense. |
just an FYI, Stephen, the : operator doesn't work with this, even though it seems like it should. It outputs a syntax error - error: :: expected end of statement, upon compile. I think that's enough to make this not redundant, as it currently doesn't work as expected.
|
I don't think allowing somelist[1]:someproc() as valid syntax is a good idea. It's strictly better in all cases to enforce type casting.
|
In response to MisterPerson
|
|
MisterPerson wrote:
I don't think allowing somelist[1]:someproc() as valid syntax is a good idea. It's strictly better in all cases to enforce type casting. Sure, type casting is always the best course of action, but the colon operator exists for that very reason. The thing is that it /is/ a valid syntax, in cases where it's not a list element. If it's just a variable, it's perfectly fine. You don't need to typecast to make this work. You just need to create a variable pointing to the list element. What is being asked for: make the colon operator work as expected with all potential pointers to objects, as that's the entire point of the colon operator. |
In response to Super Saiyan X
|
|
Super Saiyan X wrote:
MisterPerson wrote: I agree, we are experiencing an issue where the : does not operate as expected within the functionality specification of the language. If anything, it's a bug that it isn't working as designed, as you yourself just said Stephen. |
What is being asked for: make the colon operator work as expected with all potential pointers to objects, as that's the entire point of the colon operator. I wholeheartedly agree. It doesn't make sense that BYOND's members are differentiated between variables and procs and verbs. Fact of the matter is that nearly every other language doesn't differentiate these things on a functional level. Members are members, and accesses are accesses. () is an operator, and : is an operator. Why should they both not work in tandem? Not only that, but the way BYOND's VM is optimized (read: very little at best, not at all at worst), casting is kind of a big deal in performance terms when you really start to look at it. Now, you might look at Call() as being an alternative too, but without casting the type into a datum first, you will get a safety check because it assumes that you are running DLL functions. Redundant is the wrong call here, because neither typecasting nor Call() are the same thing as expanding ":" to methods. |
Another issue that I think could be resolved is that the default return variable (.) is not compatible with the runtime search operator (:).
There are cases where you might want to set a proc's default return var to an object, before accessing its variables or procedures, but attempting to do something like: . = new /mob/enemy currently just confuses the compiler. |
Well, marking status works a little better if OP doesn't edit the topic after I've marked the status in question.
I'll shift this over to bug reports, but I have a feeling that due to the error being spat out, that it's a lexer/compiler faux pas, and possibly not the more straight-forward to fix. |
In response to Stephen001
|
|
Stephen001 wrote:
Well, marking status works a little better if OP doesn't edit the topic after I've marked the status in question. |
You already can?