Herds
  • Connexion
  • Public

    • Public
    • Groupes
    • En vedette
    • Popular

Conversation

Avis

  1. Statut de Elias Mårtenson (loke@functional.cafe) sur Saturday, 02-Jan-2021 11:38:38 CET Elias Mårtenson Elias Mårtenson

    I have had some problems figuring out the best way to define functions in KAP. I wrote a post about it. I understand most people will not find this interesting, but there may be a few that does. https://write.as/loke/function-definition-syntax-in-kap

    In conversation il y a environ 8 heures de functional.cafe lien permanent

    Pièces jointes

    1. Function definition syntax in KAP
      from Elias Mårtenson
      Up until now function definition in KAP has been incomplete. It works, but the syntax is a bit cumbersome, you can't easily declare local...
    • Statut de Alex Schroeder (kensanata@octodon.social) sur Saturday, 02-Jan-2021 11:38:38 CET Alex Schroeder Alex Schroeder
      in reply to

      @loke some random thoughts, perhaps they inspire something: in Perl, my $foo is a lexical variable, local $foo is a dynamic variable (elisp dynamic binding), and our $foo is a global binding. So I use ‘our’ whenever my code loads config files that might want to modify said variables. Sounds like a similar case.

      In conversation il y a environ 8 heures lien permanent
    • Statut de Alex Schroeder (kensanata@octodon.social) sur Saturday, 02-Jan-2021 11:44:49 CET Alex Schroeder Alex Schroeder
      in reply to

      @loke perhaps you can use extra symbols to declare a global function instead of having all of the, be global by default. It’s like an “export this” symbol. ∀ probably already has a meaning, but something like:∀ ∇ (arg0;arg1) functionName (arg2;arg3) { ... }

      In conversation il y a environ 8 heures lien permanent
    • Statut de Alex Schroeder (kensanata@octodon.social) sur Saturday, 02-Jan-2021 11:49:42 CET Alex Schroeder Alex Schroeder
      in reply to

      @loke for short forms, keep the ∇ and lose the arrow?

      ∇ (arg0;arg1) functionName (arg2;arg3) { ... }∇ functionName { ... }

      In conversation il y a environ 8 heures lien permanent
    • Statut de Elias Mårtenson (loke@functional.cafe) sur Saturday, 02-Jan-2021 11:51:15 CET Elias Mårtenson Elias Mårtenson
      in reply to
      • Alex Schroeder

      @kensanata Hmm. It's not terrible. It does require the caller to know the behaviour of the thing it calls though, which can be tricky.

      The problem is (and this is self-inflicted, I know) that if you assign to a previously unassigned variable, then the assignment is local and will only apply to the current scope.

      However, if you assign to a variable which has been assigned in a higher scope, then it will change that variable. In other words, if your included file contains something as simple as foo ← bar, then foo will be local. But if a higher scope has referenced foo before, then it will affect that variable.

      In conversation il y a environ 8 heures lien permanent
    • Statut de Alex Schroeder (kensanata@octodon.social) sur Saturday, 02-Jan-2021 11:51:15 CET Alex Schroeder Alex Schroeder
      in reply to

      @loke hm, is there a way to define a new local variable of the same name? Perhaps you need this to avoid called code in libraries from clobbering your variables?

      In conversation il y a environ 8 heures lien permanent

Flux d’informations

  • Flux d’activités
  • RSS 2.0
  • Atom
  • Aide
  • À propos
  • FAQ
  • CGU
  • Confidentialité
  • Source
  • Version
  • Contact

Herds is a social network, courtesy of postblue. It runs on GNU social, version 2.0.0-alpha0, available under the GNU Affero General Public License.

Le contenu et les données de Herds sont privés et confidentiels.

Le contenu et les données sont sous le droit d’auteur du contributeur. Tous droits réservés.