[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Passing optional arguments for use with internal functions
From: |
uzibalqa |
Subject: |
Re: Passing optional arguments for use with internal functions |
Date: |
Wed, 02 Aug 2023 19:24:00 +0000 |
Sent with Proton Mail secure email.
------- Original Message -------
On Thursday, August 3rd, 2023 at 6:20 AM, Emanuel Berg <incal@dataswamp.org>
wrote:
> uzibalqa wrote:
>
> > To be absolutely sure I understand. If I want to default
> > a function optional argument if it is not used, the command
> > to that that is
> >
> > (defun dothis x ()
> > (or x (setq x 8)) ; [...]
> > (do-something x)
> > )
> >
> > And this would always work. In will work if I use the
> > lexical-binding directive at the top of a file. And it would
> > work if I use dynamic-binding directive at the top of
> > a file.
>
>
> Correct, as that wouldn't affect them because function formal
> parameters (the argument placeholders) are always under
> lexical/static scope.
>
> > Calling the command (dothis) will always use x with value 8,
> > and executing (do-something 8) .
>
>
> Yes, you forgot about the &optional keyword in your example
> but other than that it is correct.
Right, it should have been (defun dothis (&optional x)
> --
> underground experts united
> https://dataswamp.org/~incal
- Re: Passing optional arguments for use with internal functions, Emanuel Berg, 2023/08/02
- Re: Passing optional arguments for use with internal functions, uzibalqa, 2023/08/02
- Re: Passing optional arguments for use with internal functions, Emanuel Berg, 2023/08/02
- Re: Passing optional arguments for use with internal functions,
uzibalqa <=
- Re: Passing optional arguments for use with internal functions, uzibalqa, 2023/08/02
- Re: Passing optional arguments for use with internal functions, Emanuel Berg, 2023/08/04
- Re: Passing optional arguments for use with internal functions, Emanuel Berg, 2023/08/04
- Re: Passing optional arguments for use with internal functions, Emanuel Berg, 2023/08/04
- Re: Passing optional arguments for use with internal functions, Emanuel Berg, 2023/08/04