Giter Site home page Giter Site logo

Proposal: Terse Chained Indices about janet HOT 19 CLOSED

 avatar commented on May 23, 2024
Proposal: Terse Chained Indices

from janet.

Comments (19)

sogaiu avatar sogaiu commented on May 23, 2024 1

Is this similar to (get-in lookup [:b :c])?

from janet.

 avatar commented on May 23, 2024 1

from janet.

sogaiu avatar sogaiu commented on May 23, 2024 1

I wonder if there isn't code out there that uses . for their own purposes...

I'm also not so in to additional shortcuts (including a lot of user-defined macros) because I think it tends to increase the learning burden of the reader (which in turn can lead to additional costs for investigation and maintenance). One of the reasons I like lisp-likes is so I don't have to remember / learn so many exceptions.

I'm probably in the minority though (as someone who's not in to things like (1 @[:a :b :c]) (^^;

from janet.

pepe avatar pepe commented on May 23, 2024 1

@im-not-linja I am sorry to make you sad, even as I am not sure what you meant by the accusation. Can you please elaborate? Maybe DM Zulip so as not to pollute the discussion here.

from janet.

sogaiu avatar sogaiu commented on May 23, 2024 1

FWIW, there was mention from someone on one of the janet-language matrix channels that they are using . in something they are working on.

from janet.

bakpakin avatar bakpakin commented on May 23, 2024 1

Closing as I prefer the . macro. Chained lookup is useful, but there are deeper ramifications for modifying the behavior of in and get.

from janet.

 avatar commented on May 23, 2024 1

from janet.

 avatar commented on May 23, 2024

from janet.

pepe avatar pepe commented on May 23, 2024

I guess there will be a performance penalty on every lookup with just one key, as the in function (under the hood, if I am not mistaken) will always need to allocate variadic params tuple.

But I like the idea. What about . macro, which works as https://github.com/janet-lang/spork/blob/master/spork/misc.janet#L396 but with in so we can (. lookup :c :d)?

from janet.

pepe avatar pepe commented on May 23, 2024

I feel your pain, @sogaiu <3. But dot notation is evoked by this syntax, so even you will be OK.

from janet.

pepe avatar pepe commented on May 23, 2024

If it ever gets considered, that's it.

from janet.

 avatar commented on May 23, 2024

from janet.

sogaiu avatar sogaiu commented on May 23, 2024

I'm not sure of a good way to express an appropriate search -- the grep example given lacks checking for defmacro, defmacro-, and other constructs. Also, people define their own defining constructs which may then be used to define further things...

In any case, if you want to do some spelunking, this list is close to what I know about. Likely there is more stuff out there (^^;


Re: (<int> <array>) - I think this kind of thing is not that odd if one allows keyword lookup like (:a {:a 1 :b 2}) (I'm not a huge fan of that either, but it's done in at least one other lisp-like IIUC).

from janet.

 avatar commented on May 23, 2024

from janet.

iacore avatar iacore commented on May 23, 2024

I use plain syntax because the term can be put inside (set).

(def lookup @{:a 1 :b @{:c 3}})
(set ((lookup :b) :c) 4)
lookup 
# => @{:a 1 :b @{:c 4}}

This macro generates the same plain syntax.

(defmacro .
  "Recursive macro (ds key)."
  [ds & keyz]
  (reduce (fn [t key] (tuple t key)) ds keyz))

from janet.

 avatar commented on May 23, 2024

from janet.

pepe avatar pepe commented on May 23, 2024

@im-not-linja, I am still in limbo with all the puns I stole. I could indeed be a thief in some situations, but I am usually aware of it. Could you please elaborate?

from janet.

 avatar commented on May 23, 2024

from janet.

pepe avatar pepe commented on May 23, 2024

I had that feeling, but I wanted to be sure. Just so you know, I will deprecate all the standalone libraries and keep only gp (as the abbreviation of Good Place), so all the names will be free to grab :–).

from janet.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.