[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Optional Arguments
From: |
tomas |
Subject: |
Re: Optional Arguments |
Date: |
Mon, 7 Dec 2020 14:06:30 +0100 |
User-agent: |
Mutt/1.5.21 (2010-09-15) |
On Mon, Dec 07, 2020 at 01:37:34PM +0100, pietru@caramail.com wrote:
>
>
> > Sent: Monday, December 07, 2020 at 9:16 AM
> > From: "Alexis Roda" <alexis.roda.villalonga@gmail.com>
> > To: pietru@caramail.com
> > Cc: "Help Gnu Emacs" <help-gnu-emacs@gnu.org>
> > Subject: Re: Optional Arguments
> >
> > Hi,
> >
> > Not sure what your question is.
>
> It is bit confusing.
>
> I want to use typh-word-markers to compute ma and mb so I can use the
> two values in another function. Had put (interactive) in my effort to
> test it, but created problems as you say. The function would be called
> when cursor is on a word, so that I get the word "beg" and "end".
>
> (defun typh-word-markers (ma mb)
[...]
As Alexis already said, the parameters in your function aren't probably
doing what you think they do. Consider:
(setq ma 15)
(setq mb 26)
(defun foo (ma mb)
(setq ma 5)
(setq mb 6)
(message "ma: %d mb: %d" ma mb))
(foo ma mb)
=> "ma: 5 mb: 6"
(message "ma: %d mb: %d" ma mb)
=> "ma: 15 mb: 26"
I suspect you are passing the parameters to get their values
"outside" the function. I can only guess that, because you don't
show any context (take this into account to help others help
you :)
But this won't work, because the (setq ...) whithin the function
doesn't "see" the variables outside, but creates variables inside,
initialized to whatever /values/ you pass to the function at call
time.
In other words: what would you expect your function `typh-word-markers'
do do if you call it like so:
(typh-word-markers 15 16)
...would you expect it to change the number 15 to whatever the word's
beginning position is? You would mess up maths with that :)
Cheers
- t
signature.asc
Description: Digital signature
- Optional Arguments, pietru, 2020/12/06
- Re: Optional Arguments, Alexis Roda, 2020/12/07
- Re: Optional Arguments, pietru, 2020/12/07
- Re: Optional Arguments,
tomas <=
- Re: Optional Arguments, Anders Dalskov, 2020/12/07
- Re: Optional Arguments, pietru, 2020/12/07
- Re: Optional Arguments, tomas, 2020/12/07
- Re: Optional Arguments, pietru, 2020/12/07
- Re: Optional Arguments, Arthur Miller, 2020/12/07
- Re: Optional Arguments, pietru, 2020/12/07
- Re: Optional Arguments, Michael Heerdegen, 2020/12/07
- Re: Optional Arguments, pietru, 2020/12/07
- Re: Optional Arguments, Arthur Miller, 2020/12/07
- Re: Optional Arguments, pietru, 2020/12/07