Hacker Newsnew | past | comments | ask | show | jobs | submit | jpavel2's commentslogin

I absolutely love this project - for years I'd been using a homegrown s-exp to MathML translator, but your project is both more intuitive and capable.

mathup's tiny, clean API makes it easy to integrate the project in all sorts of processing workflows, both in-browser and scripting.


Thank you. I’m glad you like it.


I'm not seeing this local scope leak with bash 5.2.15. The below script works as I'd expect:

  #!/bin/bash
  
  declare -A map1=([x]=2)
  echo "1. Global scope map1[x]: ${map1[x]}"
  
  func1() {
      echo " * Enter func1"
      local -A map1
      map1[x]=3
      echo "   Local scope map1[x]: ${map1[x]}"
  }
  
  func1
  
  echo "2. Global scope map1[x]: ${map1[x]}"
outputting

  1. Global scope map1[x]: 2
   * Enter func1
     Local scope map1[x]: 3
  2. Global scope map1[x]: 2


The local scope leak seems to only happen when you drop down the call stack. See below how I can call func2 from the top level and it's fine, but if I call it from within func1, it will leak.

  #!/bin/bash
  
  declare -A map1=([x]=2)
  echo "1. Global scope map1[x]: ${map1[x]}"
  func1() {
      echo " * Enter func1"
      local -A map1
      map1[x]=3
      echo "   Local scope map1[x]: ${map1[x]}"
      func2
  }
  func2() {
      echo "  * Enter func2"
      echo "      Local scope map1[x]: ${map1[x]}"
  }
  func1
  func2
  echo "2. Global scope map1[x]: ${map1[x]}"
outputing: 1. Global scope map1[x]: 2 * Enter func1 Local scope map1[x]: 3 * Enter func2 Local scope map1[x]: 3 * Enter func2 Local scope map1[x]: 2 2. Global scope map1[x]: 2

UPDATE: I did a bit of exploration and it turns out ANY variable declared `local` is in the scope of a function lower down in the call stack. But if you declare a variable as `local` in a called function that shadows the name of a variable in a callee function, it will shadow the callee's name and reset the variable back to the vallee's value when the function returns. I have been writing bash for years and did not realise this is the case. It is even described in the man page: When local is used within a function, it causes the variable name to have a visible scope restricted to that function and its children.

Thank you. You have taught me two things today. One is a bash feature I did not know existed. The second is a new reason to avoid writing complex bash.


This is know as dynamic scope, as opposed to lexical scope: https://en.wikipedia.org/wiki/Scope_(computer_science)#Lexic...


If you're a DeluxePaint fan, then GrafX2 is the way to go these days.


Eh, maybe not looking for something quite that faithful to the original. But good to know!


This was in 2014. Since then, Vim has added non-obsolete encryption algorithms (some provided by libsodium), used by default.


I write a variety of CLI tools for my own use in Java.

On this low-end Chromebook (Samsung Chromebook 3 with a Celeron N3060 @1.60GHz) I can start the JVM, load the classes for my CLI program, and print a help message,

    jpavel@penguin:~$ time rcr -h
    Usage: RCloner <config path> get|put <entry> [args]
           RCloner <config path> list
    
    real    0m0.316s
    user    0m0.208s
    sys     0m0.126s
in less than 1/3 of a second. And this is with stock openjdk version 1.8.0_302, which doesn't include the startup time improvements of Java 10 & 12.

Sure, I wouldn't write utilities meant to be piped one into another, but for standalone CLI tools, the JVM startup time isn't prohibitive at all.


I think he was talking more about serverless functions, where 300ms longer for answering an HTTP-request would be pretty long.


See GraalVM: https://quarkus.io/


An actively developed and mature text UI library for the JVM:

https://github.com/mabe02/lanterna


Consider applying for YC's Fall 2026 batch! Applications are open till July 27.

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: