S
sln
I'm a stronger C++ programmer than Perl.
On another thread posted recently, someone was having a
problem with "sysread", passing in the correct buffer
variable. He assigned an intermediate variable to hold the
correct variable to pass in to sysread.
I was a little taken aback, not by this confusion, but by
the fact that Perl's "sysread" (and all the reads) take a
parameter that is a pure scalar variable.
This seemed kind of weird to me since to populate an external
buffer from within a user subroutine, a reference has to be passed in.
Apparently, this doesen't apply to Perl's builtin functions.
I started thinking about C conventions.
In C, there is a concept of "char a[10];", a character array, which
isin't present in Perl, the language, constuct's.
Conceptually, in C, the core language, it has always been pass by value
or pass by reference (or pointer).
In C, this applies to language core lib calls AND user defined function
calls (I say 'C' but "C++" is no different).
I understand that the smallest data unit is SCALAR, however what I can't
understand this distinction:
In C, you can't pass the address of a character to a function (system or user)
that isn't in a character array. char a[10]; function(a,,,) is really
function(&a[0],,,), the "address of a" is passed. Where char a; function(a,,,,),
the "value in a" is passed.
On the other hand, passing a reference of "a" to a function is assignable
within the function.
So what I find dificult to concieve of is why, or how, Perl can take a seeming
"pass by value" in any other function call, and turn it into an assignable
address (or reference) in a Perl function call without having to actually
pass in a reference to the buffer.
My only guess is that Perl parses and interprets its own call's different
than subroutine calls.
Thats my best guess, and its just a guess.
sln
("Don't taze me bro!")
On another thread posted recently, someone was having a
problem with "sysread", passing in the correct buffer
variable. He assigned an intermediate variable to hold the
correct variable to pass in to sysread.
I was a little taken aback, not by this confusion, but by
the fact that Perl's "sysread" (and all the reads) take a
parameter that is a pure scalar variable.
This seemed kind of weird to me since to populate an external
buffer from within a user subroutine, a reference has to be passed in.
Apparently, this doesen't apply to Perl's builtin functions.
I started thinking about C conventions.
In C, there is a concept of "char a[10];", a character array, which
isin't present in Perl, the language, constuct's.
Conceptually, in C, the core language, it has always been pass by value
or pass by reference (or pointer).
In C, this applies to language core lib calls AND user defined function
calls (I say 'C' but "C++" is no different).
I understand that the smallest data unit is SCALAR, however what I can't
understand this distinction:
In C, you can't pass the address of a character to a function (system or user)
that isn't in a character array. char a[10]; function(a,,,) is really
function(&a[0],,,), the "address of a" is passed. Where char a; function(a,,,,),
the "value in a" is passed.
On the other hand, passing a reference of "a" to a function is assignable
within the function.
So what I find dificult to concieve of is why, or how, Perl can take a seeming
"pass by value" in any other function call, and turn it into an assignable
address (or reference) in a Perl function call without having to actually
pass in a reference to the buffer.
My only guess is that Perl parses and interprets its own call's different
than subroutine calls.
Thats my best guess, and its just a guess.
sln
("Don't taze me bro!")