Fork me on GitHub
#beginners
<
2017-04-27
>
Drew Verlee01:04:06

@noisesmith Yep, fantastic. Thanks for the example

Drew Verlee01:04:25

Is it still the case that Java doesn’t have any way to extend an existing class?

Drew Verlee01:04:33

I can google this..

noisesmith01:04:37

right - we can't really expect that to change

noisesmith01:04:46

with protocols, we can extend the protocol from outside the class

jeff.engebretsen01:04:43

I’m working in ClojureScript. I’m unable to call a few core functions [`get` keys] due to TypeError: not a function problems.

jeff.engebretsen01:04:03

here’s the trace for keys Uncaught TypeError: coll.cljs$core$ISeqable$_seq$arity$1 is not a function at Object.cljs$core$seq [as seq] (core.cljs:1125) at cljs$core$keys (core.cljs:8331)

noisesmith01:04:36

wow, that's odd, my first instinct there would be bad caching, second instinct would be a namespace so broken that you get undefined behavior

noisesmith01:04:53

if it's bad caching and you are using lein, lein clean would fix it

jeff.engebretsen01:04:55

I deleted the build dirs, still happening.

noisesmith01:04:51

@drewverlee one valid way to interpret "any way to extend an existing class" is to make it a question about inheritance (which is how you extend things in java), but we use String directly for string literals (I guess an implementation decision could have been made to implement an alternate CharSequence that was also callable but that seems like it is getting out into the weeds quite a bit)

jeff.engebretsen01:04:57

Here’s (:key map) Uncaught TypeError: o.cljs$core$ILookup$_lookup$arity$2 is not a function at Function.cljs.core.get.cljs$core$IFn$_invoke$arity$2 (core.cljs:1836) at cljs.core.Keyword.cljs$core$IFn$_invoke$arity$1 (core.cljs:3172)

noisesmith01:04:43

umm, arity$2 should be :key with two args, not just one if I'm not mistaken

noisesmith01:04:56

but :key can take two args so there's still weirdness here

jeff.engebretsen01:04:48

line 3172 calls this for the two args (-invoke [kw coll] (get coll kw))

noisesmith01:04:58

eg. (:key) in my cljs repl complains that arity$0 is not a function

jeff.engebretsen01:04:39

It’s puking here (-lookup ^not-native o k) in get

noisesmith01:04:56

that's weird - makes me think something is wrong on a build tool level (though I have seen things go bonkers for odd reasons) - anything suspicious in recent changes to your codebase? you could try selectively undoing changes in a new branch to find the culprit

jeff.engebretsen01:04:03

It’s a relatively new project. Here’s the build call and the top chunk of the single source file.

(cljs.build.api/watch "src/ui"
                      {:main 'theme-previewer.renderer
                       :output-dir "app"
                       :output-to "app/main.js"})
(ns theme-previewer.renderer
  (:require [cljs.nodejs :as nodejs]))

(def Electron (nodejs/require "electron"))
(def path (nodejs/require "path"))
(def fs (nodejs/require "fs"))

(.on (.-ipcRenderer Electron) "theme-path",
     (fn [sender payload]
       (.log js/console payload)
       (.log js/console (keys payload))

noisesmith01:04:34

that seems legit...

jeff.engebretsen01:04:31

hm. I’ll go hammock it out, maybe I can get it working in the morning.

matan05:04:10

@drewverlee just small help. think about strings, they have an encoding (subtypes of UTF, ISO, other). they are something that is meant to be displayed to a user (or written to an external data store, from which they will ultimately be used for display to the user). keywords don't have these semantics, they are purer (no encoding involved) and their semantics are just a means of communication between you and the compiler

matan05:04:28

oops old question

not-raspberry10:04:24

@jeff.engebretsen I'd bisect rather than hammock.

not-raspberry10:04:15

(not necessarily with git bisect, I normally do that manually, because I always get git bisect wrong)

jeff.engebretsen12:04:08

There's nothing to bisect, it works without map operators but breaks with.

not-raspberry12:04:00

But it started occurring after something was changed/added. I'd track the culprit commit first.

jeff.engebretsen13:04:04

The change was adding (:key map). The project is 1 day old with ~30 lines.

josh.freckleton23:04:26

what's a good way to have a function be polymorphic according to an input's type? or is that an anti-pattern?

Drew Verlee23:04:48

@josh.freckleton Protocals dispatch via type

Drew Verlee23:04:02

its not an anti pattern. I think multimethods are strickly more flexible, but protocals are more performant.