hsweeney / javapp

Multiple versions of a tool to emulate 'javap -p'.
0 stars 0 forks source link

modsToString too clunky #1

Open hsweeney opened 3 years ago

hsweeney commented 3 years ago

(defn modsToString [mods] "Human-readable modifiers" (def words []) (defn wp [w] (def words (conj words w))) ; there's gotta be a better way. Recursion? (if (Modifier/isPublic mods) (wp "public")) (if (Modifier/isPrivate mods) (wp "private")) (if (Modifier/isProtected mods) (wp "protected")) (if (Modifier/isStatic mods) (wp "static")) (if (Modifier/isFinal mods) (wp "final")) (if (Modifier/isSynchronized mods) (wp "synchronized")) (if (Modifier/isVolatile mods) (wp "volatile")) (if (Modifier/isTransient mods) (wp "transient")) (if (Modifier/isInterface mods) (wp "interface")) (if (Modifier/isAbstract mods) (wp "abstract")) (if (Modifier/isStrict mods) (wp "strict")) (clojure.string/join " " words))

hsweeney commented 3 years ago

(defn modsToString [mods] "Human-readable modifiers" (def words []) (defn wp [w] (def words (conj words w))) ; there's gotta be a better way. Recursion? (if (Modifier/isPublic mods) (wp "public")) (if (Modifier/isPrivate mods) (wp "private")) (if (Modifier/isProtected mods) (wp "protected")) (if (Modifier/isStatic mods) (wp "static")) (if (Modifier/isFinal mods) (wp "final")) (if (Modifier/isSynchronized mods) (wp "synchronized")) (if (Modifier/isVolatile mods) (wp "volatile")) (if (Modifier/isTransient mods) (wp "transient")) (if (Modifier/isInterface mods) (wp "interface")) (if (Modifier/isAbstract mods) (wp "abstract")) (if (Modifier/isStrict mods) (wp "strict")) (clojure.string/join " " words))

hsweeney commented 3 years ago
(defn modsToString [mods]   "Human-readable modifiers"
  (def words [])
  (defn wp [w] (def words (conj words w)))  ; there's gotta be a better way. Recursion?
    (if (Modifier/isPublic mods)        (wp "public"))
    (if (Modifier/isPrivate mods)       (wp "private"))
    (if (Modifier/isProtected mods)     (wp "protected"))
    (if (Modifier/isStatic mods)          (wp "static"))
    (if (Modifier/isFinal mods)           (wp "final"))
    (if (Modifier/isSynchronized mods)  (wp "synchronized"))
    (if (Modifier/isVolatile mods)      (wp "volatile"))
    (if (Modifier/isTransient mods)     (wp "transient"))
    (if (Modifier/isInterface mods)     (wp "interface"))
    (if (Modifier/isAbstract mods)      (wp "abstract"))
    (if (Modifier/isStrict mods)          (wp "strict"))
(clojure.string/join " " words))