Arguments - Struct or Array

115 views
Skip to first unread message

Adrian Lynch

unread,
Apr 1, 2014, 10:21:13 AM4/1/14
to ra...@googlegroups.com
If you had to choose to treat the arguments scope as a structure or array when using its member functions, would you prefer an array or a structure?

Based on this:


arguments.find("A value in the arguments scope") // Array - Works

arguments.keyExists("anArgumentName") // Structure - Fails

I almost exclusively treat it as a structure.

What about the rest of yas?

Adrian


Chris Blackwell

unread,
Apr 1, 2014, 10:33:09 AM4/1/14
to railo
struct


--
Did you find this reply useful? Help the Railo community and add it to the Railo Server wiki at https://github.com/getrailo/railo/wiki
---
You received this message because you are subscribed to the Google Groups "Railo" group.
To view this discussion on the web visit https://groups.google.com/d/msgid/railo/CAH368SRc78aVqePUTntm65O%3DpQhdVfdO1f0po2ReQeD08r3R-Q%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Igal @ getRailo.org

unread,
Apr 1, 2014, 10:39:59 AM4/1/14
to ra...@googlegroups.com
Struct -- definitely

For more options, visit https://groups.google.com/d/optout.

-- 
Igal Sapir
Railo Core Developer
http://getRailo.org/

Carl Von Stetten

unread,
Apr 1, 2014, 2:09:22 PM4/1/14
to ra...@googlegroups.com
+1 - struct.
-Carl V.

Adam Cameron

unread,
Apr 1, 2014, 2:12:56 PM4/1/14
to ra...@googlegroups.com


On Tuesday, 1 April 2014 15:21:13 UTC+1, Adrian Lynch wrote:
If you had to choose to treat the arguments scope as a structure or array when using its member functions, would you prefer an array or a structure?
 

Why are we limiting this to an either/or scenario? The arguments scope is neither a struct nor an array, although it implements behaviour of both. So why not just reflect this in its methods?

-- 
Adam

Matt Quackenbush

unread,
Apr 1, 2014, 2:14:14 PM4/1/14
to ra...@googlegroups.com
Ayep. Struct.


Michael Offner

unread,
Apr 2, 2014, 2:11:30 AM4/2/14
to ra...@googlegroups.com
struct



For more options, visit https://groups.google.com/d/optout.



--
/micha

Michael Offner CTO Railo Technologies GmbH

Michael Offner

unread,
Apr 2, 2014, 2:30:29 AM4/2/14
to ra...@googlegroups.com
because it is confusing, see list/string function discussion

Micha


--
Did you find this reply useful? Help the Railo community and add it to the Railo Server wiki at https://github.com/getrailo/railo/wiki
---
You received this message because you are subscribed to the Google Groups "Railo" group.

For more options, visit https://groups.google.com/d/optout.

Adam Cameron

unread,
Apr 2, 2014, 8:32:08 AM4/2/14
to ra...@googlegroups.com
No, it's not.

What would be confusing would be to implement member functions in a way that don't match of the thing can be used with "procedural" functions. if I can call arrayLen(arguments), then I should be able to call arguments.len() (or whatever). Where there is a conflict (say the array "interface" and struct "interface" have same-named methods), then you'll need to give it some additional thought as to how to deal with that.

The arguments scope is not a struct, so it would be "confusing" to implement its member functions as it it were.

-- 
Adam

Adam Cameron

unread,
Apr 2, 2014, 8:41:00 AM4/2/14
to ra...@googlegroups.com
Oh, and might I add you are beginning to start to sound like Adobe, second-guessing how thick you perceive your community's developers are, and making dumbed-down decisions on that basis.

If someone gets confused (and, hey, I'm not saying some people won't!), then they will either very quickly work out what's going on by reading the docs (oh hohohoho) or asking here / StackOverflow / etc. Then they will not be confused. Or they will be the sort of person who never stops being confused, and will not be helped, but there's no point in specifically addressing that sort of person, because they probably won't be using this stuff anyhow.

-- 
Adam

Todd

unread,
Apr 2, 2014, 8:47:05 AM4/2/14
to ra...@googlegroups.com
Zing? :)

On Wed, Apr 2, 2014 at 8:41 AM, Adam Cameron <dac...@gmail.com> wrote:
then they will either very quickly work out what's going on by reading the docs (oh hohohoho)
-- 
Adam

Michael Offner

unread,
Apr 2, 2014, 9:34:42 AM4/2/14
to ra...@googlegroups.com
See my comments between the lines

Micha


2014-04-02 14:32 GMT+02:00 Adam Cameron <dac...@gmail.com>:
No, it's not.

What would be confusing would be to implement member functions in a way that don't match of the thing can be used with "procedural" functions. if I can call arrayLen(arguments), then I should be able to call arguments.len() (or whatever). Where there is a conflict (say the array "interface" and struct "interface" have same-named methods), then you'll need to give it some additional thought as to how to deal with that.

The arguments scope is not a struct,

<cfscript>
  function test(){
  writeOutput(isStruct(arguments)); // Railo/ACF:true
  writeOutput(isArray(arguments)); // Railo:true;ACF:false
  }
  test();
</cfscript>
 
so it would be "confusing" to implement its member functions as it it were.

-- 
Adam


On Wednesday, 2 April 2014 07:30:29 UTC+1, Michael Offner wrote:
because it is confusing, see list/string function discussion

Micha


2014-04-01 20:12 GMT+02:00 Adam Cameron <dac...@gmail.com>:



On Tuesday, 1 April 2014 15:21:13 UTC+1, Adrian Lynch wrote:
If you had to choose to treat the arguments scope as a structure or array when using its member functions, would you prefer an array or a structure?
 

Why are we limiting this to an either/or scenario? The arguments scope is neither a struct nor an array, although it implements behaviour of both. So why not just reflect this in its methods?

--
Did you find this reply useful? Help the Railo community and add it to the Railo Server wiki at https://github.com/getrailo/railo/wiki
---
You received this message because you are subscribed to the Google Groups "Railo" group.

For more options, visit https://groups.google.com/d/optout.

Michael Offner

unread,
Apr 2, 2014, 9:43:18 AM4/2/14
to ra...@googlegroups.com
again between the lines

Micha


2014-04-02 14:41 GMT+02:00 Adam Cameron <dac...@gmail.com>:
Oh, and might I add you are beginning to start to sound like Adobe,

that hurts ;-)
 
second-guessing how thick you perceive your community's developers are, and making dumbed-down decisions on that basis.

If someone gets confused (and, hey, I'm not saying some people won't!), then they will either very quickly work out what's going on by reading the docs (oh hohohoho) or asking here / StackOverflow / etc. Then they will not be confused. Or they will be the sort of person who never stops being confused, and will not be helped, but there's no point in specifically addressing that sort of person, because they probably won't be using this stuff anyhow.
i asked myself, what is a "arguments" scope for me, a array a struct or both?
For me it is clearly a s struct that can be used as array, but it is not a array.
Like a men wearing women's clothes.
So maybe it is just confusing for me ... (the arguments scope not the clothes)
 

-- 
Adam


On Wednesday, 2 April 2014 13:32:08 UTC+1, Adam Cameron wrote:
No, it's not.

What would be confusing would be to implement member functions in a way that don't match of the thing can be used with "procedural" functions. if I can call arrayLen(arguments), then I should be able to call arguments.len() (or whatever). Where there is a conflict (say the array "interface" and struct "interface" have same-named methods), then you'll need to give it some additional thought as to how to deal with that.

The arguments scope is not a struct, so it would be "confusing" to implement its member functions as it it were.

-- 
Adam

On Wednesday, 2 April 2014 07:30:29 UTC+1, Michael Offner wrote:
because it is confusing, see list/string function discussion

Micha


2014-04-01 20:12 GMT+02:00 Adam Cameron <dac...@gmail.com>:


On Tuesday, 1 April 2014 15:21:13 UTC+1, Adrian Lynch wrote:
If you had to choose to treat the arguments scope as a structure or array when using its member functions, would you prefer an array or a structure?
 

Why are we limiting this to an either/or scenario? The arguments scope is neither a struct nor an array, although it implements behaviour of both. So why not just reflect this in its methods?

--
Did you find this reply useful? Help the Railo community and add it to the Railo Server wiki at https://github.com/getrailo/railo/wiki
---
You received this message because you are subscribed to the Google Groups "Railo" group.

For more options, visit https://groups.google.com/d/optout.

Adam Cameron

unread,
Apr 2, 2014, 9:48:30 AM4/2/14
to ra...@googlegroups.com

<cfscript>
  function test(){
  writeOutput(isStruct(arguments)); // Railo/ACF:true
  writeOutput(isArray(arguments)); // Railo:true;ACF:false
  }
  test();
</cfscript>
 


FFS, Micha. Stop being (purposely, I suspect) obtuse:

function f(){
var a = []
var st = {}
dump([
arguments.getClass().getName(),
a.getClass().getName(),
st.getClass().getName()
])
dump([
arrayLen(arguments),
structCount(arguments)
])
}
f(a=1)

Array
1
stringrailo.runtime.type.scope.ArgumentImpl
2
stringrailo.runtime.type.ArrayImpl
3
stringrailo.runtime.type.StructImpl
Array
1
number1
2
number1

 It. Is. Not. A. Struct.

Can you please stop wasting everyone's time trying to suggest that it is.

-- 
Adam

Adam Cameron

unread,
Apr 2, 2014, 9:54:18 AM4/2/14
to ra...@googlegroups.com

2014-04-02 14:41 GMT+02:00 Adam Cameron <dac...@gmail.com>:
Oh, and might I add you are beginning to start to sound like Adobe,

that hurts ;-)

Well there you go.

 
i asked myself, what is a "arguments" scope for me, a array a struct or both?
For me it is clearly a s struct that can be used as array, but it is not a array.

Well - like I said - it's neither but it behaves like both. Which is not at all confusing if one considers that classes implement multiple interfaces all the time.

But no matter how many times you say it, it's not struct.
 
 
So maybe it is just confusing for me ... (the arguments scope not the clothes)

Photos pls. I think we should determine how confused you look in this situation.

-- 
Adam

Michael Offner

unread,
Apr 2, 2014, 10:43:12 AM4/2/14
to ra...@googlegroups.com
From technical perspective it is clearly a struct, because ArgumentImpl does implement the interface Struct, like every other scope as well!
because of that you can use scopes with all struct functions ...
That is out of the question (from technical perspective)! 
Special is that the ArgumentImpl class implements the interface Array as well ...

Micha



--
Did you find this reply useful? Help the Railo community and add it to the Railo Server wiki at https://github.com/getrailo/railo/wiki
---
You received this message because you are subscribed to the Google Groups "Railo" group.

For more options, visit https://groups.google.com/d/optout.

ML

unread,
Jul 19, 2014, 9:47:42 AM7/19/14
to ra...@googlegroups.com
Hi,

I have always thought that the arguments scope was a struct.  Until I started getting error on this piece of code.  Can't cast [a] string to a number value

    function printArgs(  ){

        arguments
.each( function( key ){
           
dump( key );
       
})
   
}

    printArgs
( a = 1, b = 2, c = 3 );


Since .each() is supposed to be implemented for both struct and array, it seems that arguments is neither.  Or is this a bug?

Interestingly, this works:

    function printArgs(  ){

       
for( key in arguments )
           
dump( key );
   
}

    printArgs
( a = 1, b = 2, c = 3 );

ML

unread,
Jul 19, 2014, 10:26:48 AM7/19/14
to ra...@googlegroups.com

Casting the arguments into a struct gives the same error.

    function printArgs( ){

        printStruct
( arguments );

   
}

   
function printStruct( struct data ){

        arguments
.data.each( function( key ){
           
dump( key );
       
})

   
}

    printArgs
( a = 1, b = 2, c = 3 );  // this throws an error: Can't cast [a] string to a number value
    printStruct
(  { a = 1, b = 2, c = 3 } );  // this works

Adam Cameron

unread,
Jul 19, 2014, 10:40:32 AM7/19/14
to ra...@googlegroups.com
I agree this is a bug. You should raise it as such.

Whilst checking this, I noticed a different bug in ColdFusion with the same code, as it happens. Details here, for those who are interested: http://cfmlblog.adamcameron.me/2014/07/different-bugs-in-each-function-in-each.html

-- 
Adam

ML

unread,
Jul 19, 2014, 11:47:35 AM7/19/14
to ra...@googlegroups.com
Done.  Thanks for verifying the bug.

https://issues.jboss.org/browse/RAILO-3129
Reply all
Reply to author
Forward
0 new messages