1. Maybe not so stupid a question?



include mylog..e
------------------------------------------------part of
mylog.e----------------------------------
global test(object aaa)
   if sequence(aaa) then
       printf(1,"length(%s)=%d,{aaa,length(aaa)})--right here
   end if
end procedure
--------------------------------------main program--------------------------
dog="mutt"
test(dog)

Hello everyone,  

Maybe someone can help.

Where it says "right here" the first %s refers to aaa which will print out
"mutt" the variable held in dog.

But I don't want to print that I want to print the word "dog" the name of my
variable.

Can this be done"?

Don Cole

new topic     » topic index » view message » categorize

2. Re: Maybe not so stupid a question?

don cole wrote:
> 
> 
> }}}
<eucode>
> include mylog..e
> ------------------------------------------------part of
> mylog.e----------------------------------
> global test(object aaa)
>    if sequence(aaa) then
>        printf(1,"length(%s)=%d,{aaa,length(aaa)})--right here

printf(1,"length(%s)=%d", {aaa,length(aaa)} )

your asking it to print out a variable name - theres probably a deep hack to do
this, but I don't know what it is. A simpler generic solution would be

include mylog..e
------------------------------------------------part of
mylog.e----------------------------------
global test(object aaa, sequence var_name)
   if sequence(aaa) then
       printf(1,"length(%s),=%d for %s,{var_name,length(aaa), aaa})--right here
   end if
end procedure
--------------------------------------main program--------------------------
dog="mutt"
test(dog, "dog")


>    end if
> end procedure
> --------------------------------------main program--------------------------
> dog="mutt"
> test(dog)
> </eucode>
{{{

> Hello everyone,  
> 
> Maybe someone can help.
> 
> Where it says "right here" the first %s refers to aaa which will print out
> "mutt"
> the variable held in dog.
> 
> But I don't want to print that I want to print the word "dog" the name of my
> variable.
> 
> Can this be done"?
> 
> Don Cole



http://euallegro.wikispaces.com
http://members.aol.com/chriscrylex/euphoria.htm
http://uboard.proboards32.com/
http://members.aol.com/chriscrylex/EUSQLite/eusql.html

new topic     » goto parent     » topic index » view message » categorize

3. Re: Maybe not so stupid a question?

Chris Burch wrote:
> 
> don cole wrote:
> > 
> > 
> > }}}
<eucode>
> > include mylog..e
> > ------------------------------------------------part of
> > mylog.e----------------------------------
> > global test(object aaa)
> >    if sequence(aaa) then
> >        printf(1,"length(%s)=%d,{aaa,length(aaa)})--right here
> 
> printf(1,"length(%s)=%d", {aaa,length(aaa)} )
> 
> your asking it to print out a variable name - theres probably a deep hack to
> do this,
> but I don't know what it is. A simpler generic solution would be
> 
> }}}
<eucode>
> include mylog..e
> ------------------------------------------------part of
> mylog.e----------------------------------
> global test(object aaa, sequence var_name)
>    if sequence(aaa) then
>        printf(1,"length(%s),=%d for %s,{var_name,length(aaa), aaa})--right
>        here
>    end if
> end procedure
> --------------------------------------main program--------------------------
> dog="mutt"
> test(dog, "dog")
> </eucode>
{{{

> 
> >    end if
> > end procedure
> > --------------------------------------main program--------------------------
> > dog="mutt"
> > test(dog)
> > </eucode>
{{{

> > Hello everyone,  
> > 
> > Maybe someone can help.
> > 
> > Where it says "right here" the first %s refers to aaa which will print out
> > "mutt"
> > the variable held in dog.
> > 
> > But I don't want to print that I want to print the word "dog" the name of my
> > variable.
> > 
> > Can this be done"?
> > 
> > Don Cole
> 
> 
> <a href="http://euallegro.wikispaces.com">http://euallegro.wikispaces.com</a>
> <a
> href="http://members.aol.com/chriscrylex/euphoria.htm">http://members.aol.com/chriscrylex/euphoria.htm</a>
> <a href="http://uboard.proboards32.com/">http://uboard.proboards32.com/</a>
> <a
> href="http://members.aol.com/chriscrylex/EUSQLite/eusql.html">http://members.aol.com/chriscrylex/EUSQLite/eusql.html</a>

Thanks Chris,

  I don't know why I'm so stupid not to think of that.

Don Cole

new topic     » goto parent     » topic index » view message » categorize

4. Re: Maybe not so stupid a question?

don cole wrote:
> 
> Chris Burch wrote:
> > 
> > don cole wrote:
> > > 
> > > 
> > > }}}
<eucode>
> > > include mylog..e
> > > ------------------------------------------------part of
> > > mylog.e----------------------------------
> > > global test(object aaa)
> > >    if sequence(aaa) then
> > >        printf(1,"length(%s)=%d,{aaa,length(aaa)})--right here
> > 
> > printf(1,"length(%s)=%d", {aaa,length(aaa)} )
> > 
> > your asking it to print out a variable name - theres probably a deep hack to
> > do this,
> > but I don't know what it is. A simpler generic solution would be
> > 
> > }}}
<eucode>
> > include mylog..e
> > ------------------------------------------------part of
> > mylog.e----------------------------------
> > global test(object aaa, sequence var_name)
> >    if sequence(aaa) then
> >        printf(1,"length(%s),=%d for %s,{var_name,length(aaa), aaa})--right
> >        here
> >    end if
> > end procedure
> > --------------------------------------main program--------------------------
> > dog="mutt"
> > test(dog, "dog")
> > </eucode>
{{{

> > 
> > >    end if
> > > end procedure
> > > --------------------------------------main
> > > program--------------------------
> > > dog="mutt"
> > > test(dog)
> > > </eucode>
{{{

> > > Hello everyone,  
> > > 
> > > Maybe someone can help.
> > > 
> > > Where it says "right here" the first %s refers to aaa which will print out
> > > "mutt"
> > > the variable held in dog.
> > > 
> > > But I don't want to print that I want to print the word "dog" the name of
> > > my
> > > variable.
> > > 
> > > Can this be done"?
> > > 
> > > Don Cole
> > 
> > 
> > <a
> > href="http://euallegro.wikispaces.com">http://euallegro.wikispaces.com</a>
> > <a
> > href="http://members.aol.com/chriscrylex/euphoria.htm">http://members.aol.com/chriscrylex/euphoria.htm</a>
> > <a href="http://uboard.proboards32.com/">http://uboard.proboards32.com/</a>
> > <a
> > href="http://members.aol.com/chriscrylex/EUSQLite/eusql.html">http://members.aol.com/chriscrylex/EUSQLite/eusql.html</a>
> 
> Thanks Chris,
> 
>   I don't know why I'm so stupid not to think of that.
> 
> Don Cole

Euphoria is a pass by value language and has no pointer to allevuate the
problem.

Hence, when you pass <dog> as an argument, only the value is passed, possibly
as a pointer. But the target routine has no way to know where the value comes
from. And variable names don't make it to the backend part of the interpreter
anyway.

Since Matt's OOEu implements pass by reference, you should be able to code
something like:

procedure test(byref object x)
print(1,var_name(x))
end procedure

test(dog) would then print "dog". If you pass an expression, I'd expect ""
to be printed, or "_temp#01A" perhaps. But that is OOEu, not plain Euphoria.

CChris

new topic     » goto parent     » topic index » view message » categorize

5. Re: Maybe not so stupid a question?

CChris wrote:
> 
> Euphoria is a pass by value language and has no pointer to allevuate the
> problem.
> 
> Hence, when you pass <dog> as an argument, only the value is passed, possibly
> as a pointer. But the target routine has no way to know where the value comes
> from. And variable names don't make it to the backend part of the interpreter
> anyway.
> 
> Since Matt's OOEu implements pass by reference, you should be able to code
> something like:
> 
> procedure test(byref object x)
> print(1,var_name(x))
> end procedure
> 
> test(dog) would then print "dog". If you pass an expression, I'd expect ""
> to be printed, or "_temp#01A" perhaps. But that is OOEu, not plain Euphoria.

Actually, to do this, you'd need to use the var_id() family of routines
in ooeu.  There's a different pass by reference functionality that does just
that, but doesn't allow additional access to any metadata.

Matt

new topic     » goto parent     » topic index » view message » categorize

Search



Quick Links

User menu

Not signed in.

Misc Menu