xref: /OpenGrok/opengrok-indexer/src/test/resources/analysis/clojure/sample.clj (revision eeb7e5b33d1bcc524fcc9d1d560447b044e286a4)
1*eeb7e5b3SAdam Hornáček; Eclipse Public License, Version 1.0 (EPL-1.0) (plain text) THE ACCOMPANYING
2*eeb7e5b3SAdam Hornáček; PROGRAM IS PROVIDED UNDER THE TERMS OF THIS ECLIPSE PUBLIC LICENSE
3*eeb7e5b3SAdam Hornáček; ("AGREEMENT"). ANY USE, REPRODUCTION OR DISTRIBUTION OF THE PROGRAM
4*eeb7e5b3SAdam Hornáček; CONSTITUTES RECIPIENT'S ACCEPTANCE OF THIS AGREEMENT.
5*eeb7e5b3SAdam Hornáček;
6*eeb7e5b3SAdam Hornáček; 1. DEFINITIONS
7*eeb7e5b3SAdam Hornáček;
8*eeb7e5b3SAdam Hornáček; "Contribution" means:
9*eeb7e5b3SAdam Hornáček;
10*eeb7e5b3SAdam Hornáček; a) in the case of the initial Contributor, the initial code and
11*eeb7e5b3SAdam Hornáček; documentation distributed under this Agreement, and b) in the case of each
12*eeb7e5b3SAdam Hornáček; subsequent Contributor: i) changes to the Program, and ii) additions to the
13*eeb7e5b3SAdam Hornáček; Program; where such changes and/or additions to the Program originate from
14*eeb7e5b3SAdam Hornáček; and are distributed by that particular Contributor. A Contribution
15*eeb7e5b3SAdam Hornáček; 'originates' from a Contributor if it was added to the Program by such
16*eeb7e5b3SAdam Hornáček; Contributor itself or anyone acting on such Contributor's behalf.
17*eeb7e5b3SAdam Hornáček; Contributions do not include additions to the Program which: (i) are
18*eeb7e5b3SAdam Hornáček; separate modules of software distributed in conjunction with the Program
19*eeb7e5b3SAdam Hornáček; under their own license agreement, and (ii) are not derivative works of the
20*eeb7e5b3SAdam Hornáček; Program. "Contributor" means any person or entity that distributes the
21*eeb7e5b3SAdam Hornáček; Program.
22*eeb7e5b3SAdam Hornáček;
23*eeb7e5b3SAdam Hornáček; "Licensed Patents " mean patent claims licensable by a Contributor which are
24*eeb7e5b3SAdam Hornáček; necessarily infringed by the use or sale of its Contribution alone or when
25*eeb7e5b3SAdam Hornáček; combined with the Program.
26*eeb7e5b3SAdam Hornáček;
27*eeb7e5b3SAdam Hornáček; "Program" means the Contributions distributed in accordance with this
28*eeb7e5b3SAdam Hornáček; Agreement.
29*eeb7e5b3SAdam Hornáček;
30*eeb7e5b3SAdam Hornáček; "Recipient" means anyone who receives the Program under this Agreement,
31*eeb7e5b3SAdam Hornáček; including all Contributors.
32*eeb7e5b3SAdam Hornáček;
33*eeb7e5b3SAdam Hornáček; 2. GRANT OF RIGHTS
34*eeb7e5b3SAdam Hornáček;
35*eeb7e5b3SAdam Hornáček; a) Subject to the terms of this Agreement, each Contributor hereby grants
36*eeb7e5b3SAdam Hornáček; Recipient a non-exclusive, worldwide, royalty-free copyright license to
37*eeb7e5b3SAdam Hornáček; reproduce, prepare derivative works of, publicly display, publicly perform,
38*eeb7e5b3SAdam Hornáček; distribute and sublicense the Contribution of such Contributor, if any, and
39*eeb7e5b3SAdam Hornáček; such derivative works, in source code and object code form. b) Subject to
40*eeb7e5b3SAdam Hornáček; the terms of this Agreement, each Contributor hereby grants Recipient a
41*eeb7e5b3SAdam Hornáček; non-exclusive, worldwide, royalty-free patent license under Licensed Patents
42*eeb7e5b3SAdam Hornáček; to make, use, sell, offer to sell, import and otherwise transfer the
43*eeb7e5b3SAdam Hornáček; Contribution of such Contributor, if any, in source code and object code
44*eeb7e5b3SAdam Hornáček; form. This patent license shall apply to the combination of the Contribution
45*eeb7e5b3SAdam Hornáček; and the Program if, at the time the Contribution is added by the
46*eeb7e5b3SAdam Hornáček; Contributor, such addition of the Contribution causes such combination to be
47*eeb7e5b3SAdam Hornáček; covered by the Licensed Patents. The patent license shall not apply to any
48*eeb7e5b3SAdam Hornáček; other combinations which include the Contribution. No hardware per se is
49*eeb7e5b3SAdam Hornáček; licensed hereunder. c) Recipient understands that although each Contributor
50*eeb7e5b3SAdam Hornáček; grants the licenses to its Contributions set forth herein, no assurances are
51*eeb7e5b3SAdam Hornáček; provided by any Contributor that the Program does not infringe the patent or
52*eeb7e5b3SAdam Hornáček; other intellectual property rights of any other entity. Each Contributor
53*eeb7e5b3SAdam Hornáček; disclaims any liability to Recipient for claims brought by any other entity
54*eeb7e5b3SAdam Hornáček; based on infringement of intellectual property rights or otherwise. As a
55*eeb7e5b3SAdam Hornáček; condition to exercising the rights and licenses granted hereunder, each
56*eeb7e5b3SAdam Hornáček; Recipient hereby assumes sole responsibility to secure any other
57*eeb7e5b3SAdam Hornáček; intellectual property rights needed, if any. For example, if a third party
58*eeb7e5b3SAdam Hornáček; patent license is required to allow Recipient to distribute the Program, it
59*eeb7e5b3SAdam Hornáček; is Recipient's responsibility to acquire that license before distributing
60*eeb7e5b3SAdam Hornáček; the Program. d) Each Contributor represents that to its knowledge it has
61*eeb7e5b3SAdam Hornáček; sufficient copyright rights in its Contribution, if any, to grant the
62*eeb7e5b3SAdam Hornáček; copyright license set forth in this Agreement.
63*eeb7e5b3SAdam Hornáček;
64*eeb7e5b3SAdam Hornáček; 3. REQUIREMENTS
65*eeb7e5b3SAdam Hornáček;
66*eeb7e5b3SAdam Hornáček; A Contributor may choose to distribute the Program in object code form under
67*eeb7e5b3SAdam Hornáček; its own license agreement, provided that:
68*eeb7e5b3SAdam Hornáček;
69*eeb7e5b3SAdam Hornáček; a) it complies with the terms and conditions of this Agreement; and b) its
70*eeb7e5b3SAdam Hornáček; license agreement: i) effectively disclaims on behalf of all Contributors
71*eeb7e5b3SAdam Hornáček; all warranties and conditions, express and implied, including warranties or
72*eeb7e5b3SAdam Hornáček; conditions of title and non-infringement, and implied warranties or
73*eeb7e5b3SAdam Hornáček; conditions of merchantability and fitness for a particular purpose; ii)
74*eeb7e5b3SAdam Hornáček; effectively excludes on behalf of all Contributors all liability for
75*eeb7e5b3SAdam Hornáček; damages, including direct, indirect, special, incidental and consequential
76*eeb7e5b3SAdam Hornáček; damages, such as lost profits; iii) states that any provisions which differ
77*eeb7e5b3SAdam Hornáček; from this Agreement are offered by that Contributor alone and not by any
78*eeb7e5b3SAdam Hornáček; other party; and iv) states that source code for the Program is available
79*eeb7e5b3SAdam Hornáček; from such Contributor, and informs licensees how to obtain it in a
80*eeb7e5b3SAdam Hornáček; reasonable manner on or through a medium customarily used for software
81*eeb7e5b3SAdam Hornáček; exchange. When the Program is made available in source code form:
82*eeb7e5b3SAdam Hornáček;
83*eeb7e5b3SAdam Hornáček; a) it must be made available under this Agreement; and b) a copy of this
84*eeb7e5b3SAdam Hornáček; Agreement must be included with each copy of the Program. Contributors may
85*eeb7e5b3SAdam Hornáček; not remove or alter any copyright notices contained within the Program. Each
86*eeb7e5b3SAdam Hornáček; Contributor must identify itself as the originator of its Contribution, if
87*eeb7e5b3SAdam Hornáček; any, in a manner that reasonably allows subsequent Recipients to identify
88*eeb7e5b3SAdam Hornáček; the originator of the Contribution.
89*eeb7e5b3SAdam Hornáček;
90*eeb7e5b3SAdam Hornáček; 4. COMMERCIAL DISTRIBUTION
91*eeb7e5b3SAdam Hornáček;
92*eeb7e5b3SAdam Hornáček; Commercial distributors of software may accept certain responsibilities with
93*eeb7e5b3SAdam Hornáček; respect to end users, business partners and the like. While this license is
94*eeb7e5b3SAdam Hornáček; intended to facilitate the commercial use of the Program, the Contributor
95*eeb7e5b3SAdam Hornáček; who includes the Program in a commercial product offering should do so in a
96*eeb7e5b3SAdam Hornáček; manner which does not create potential liability for other Contributors.
97*eeb7e5b3SAdam Hornáček; Therefore, if a Contributor includes the Program in a commercial product
98*eeb7e5b3SAdam Hornáček; offering, such Contributor ("Commercial Contributor") hereby agrees to
99*eeb7e5b3SAdam Hornáček; defend and indemnify every other Contributor ("Indemnified Contributor")
100*eeb7e5b3SAdam Hornáček; against any losses, damages and costs (collectively "Losses") arising from
101*eeb7e5b3SAdam Hornáček; claims, lawsuits and other legal actions brought by a third party against
102*eeb7e5b3SAdam Hornáček; the Indemnified Contributor to the extent caused by the acts or omissions of
103*eeb7e5b3SAdam Hornáček; such Commercial Contributor in connection with its distribution of the
104*eeb7e5b3SAdam Hornáček; Program in a commercial product offering. The obligations in this section do
105*eeb7e5b3SAdam Hornáček; not apply to any claims or Losses relating to any actual or alleged
106*eeb7e5b3SAdam Hornáček; intellectual property infringement. In order to qualify, an Indemnified
107*eeb7e5b3SAdam Hornáček; Contributor must: a) promptly notify the Commercial Contributor in writing
108*eeb7e5b3SAdam Hornáček; of such claim, and b) allow the Commercial Contributor to control, and
109*eeb7e5b3SAdam Hornáček; cooperate with the Commercial Contributor in, the defense and any related
110*eeb7e5b3SAdam Hornáček; settlement negotiations. The Indemnified Contributor may participate in any
111*eeb7e5b3SAdam Hornáček; such claim at its own expense.
112*eeb7e5b3SAdam Hornáček;
113*eeb7e5b3SAdam Hornáček; For example, a Contributor might include the Program in a commercial product
114*eeb7e5b3SAdam Hornáček; offering, Product X. That Contributor is then a Commercial Contributor. If
115*eeb7e5b3SAdam Hornáček; that Commercial Contributor then makes performance claims, or offers
116*eeb7e5b3SAdam Hornáček; warranties related to Product X, those performance claims and warranties are
117*eeb7e5b3SAdam Hornáček; such Commercial Contributor's responsibility alone. Under this section, the
118*eeb7e5b3SAdam Hornáček; Commercial Contributor would have to defend claims against the other
119*eeb7e5b3SAdam Hornáček; Contributors related to those performance claims and warranties, and if a
120*eeb7e5b3SAdam Hornáček; court requires any other Contributor to pay any damages as a result, the
121*eeb7e5b3SAdam Hornáček; Commercial Contributor must pay those damages.
122*eeb7e5b3SAdam Hornáček;
123*eeb7e5b3SAdam Hornáček; 5. NO WARRANTY
124*eeb7e5b3SAdam Hornáček;
125*eeb7e5b3SAdam Hornáček; EXCEPT AS EXPRESSLY SET FORTH IN THIS AGREEMENT, THE PROGRAM IS PROVIDED ON
126*eeb7e5b3SAdam Hornáček; AN "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, EITHER
127*eeb7e5b3SAdam Hornáček; EXPRESS OR IMPLIED INCLUDING, WITHOUT LIMITATION, ANY WARRANTIES OR
128*eeb7e5b3SAdam Hornáček; CONDITIONS OF TITLE, NON-INFRINGEMENT, MERCHANTABILITY OR FITNESS FOR A
129*eeb7e5b3SAdam Hornáček; PARTICULAR PURPOSE. Each Recipient is solely responsible for determining the
130*eeb7e5b3SAdam Hornáček; appropriateness of using and distributing the Program and assumes all risks
131*eeb7e5b3SAdam Hornáček; associated with its exercise of rights under this Agreement , including but
132*eeb7e5b3SAdam Hornáček; not limited to the risks and costs of program errors, compliance with
133*eeb7e5b3SAdam Hornáček; applicable laws, damage to or loss of data, programs or equipment, and
134*eeb7e5b3SAdam Hornáček; unavailability or interruption of operations.
135*eeb7e5b3SAdam Hornáček;
136*eeb7e5b3SAdam Hornáček; 6. DISCLAIMER OF LIABILITY
137*eeb7e5b3SAdam Hornáček;
138*eeb7e5b3SAdam Hornáček; EXCEPT AS EXPRESSLY SET FORTH IN THIS AGREEMENT, NEITHER RECIPIENT NOR ANY
139*eeb7e5b3SAdam Hornáček; CONTRIBUTORS SHALL HAVE ANY LIABILITY FOR ANY DIRECT, INDIRECT, INCIDENTAL,
140*eeb7e5b3SAdam Hornáček; SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING WITHOUT LIMITATION
141*eeb7e5b3SAdam Hornáček; LOST PROFITS), HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
142*eeb7e5b3SAdam Hornáček; CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
143*eeb7e5b3SAdam Hornáček; ARISING IN ANY WAY OUT OF THE USE OR DISTRIBUTION OF THE PROGRAM OR THE
144*eeb7e5b3SAdam Hornáček; EXERCISE OF ANY RIGHTS GRANTED HEREUNDER, EVEN IF ADVISED OF THE POSSIBILITY
145*eeb7e5b3SAdam Hornáček; OF SUCH DAMAGES.
146*eeb7e5b3SAdam Hornáček;
147*eeb7e5b3SAdam Hornáček; 7. GENERAL
148*eeb7e5b3SAdam Hornáček;
149*eeb7e5b3SAdam Hornáček; If any provision of this Agreement is invalid or unenforceable under
150*eeb7e5b3SAdam Hornáček; applicable law, it shall not affect the validity or enforceability of the
151*eeb7e5b3SAdam Hornáček; remainder of the terms of this Agreement, and without further action by the
152*eeb7e5b3SAdam Hornáček; parties hereto, such provision shall be reformed to the minimum extent
153*eeb7e5b3SAdam Hornáček; necessary to make such provision valid and enforceable.
154*eeb7e5b3SAdam Hornáček;
155*eeb7e5b3SAdam Hornáček; If Recipient institutes patent litigation against any entity (including a
156*eeb7e5b3SAdam Hornáček; cross-claim or counterclaim in a lawsuit) alleging that the Program itself
157*eeb7e5b3SAdam Hornáček; (excluding combinations of the Program with other software or hardware)
158*eeb7e5b3SAdam Hornáček; infringes such Recipient's patent(s), then such Recipient's rights granted
159*eeb7e5b3SAdam Hornáček; under Section 2(b) shall terminate as of the date such litigation is filed.
160*eeb7e5b3SAdam Hornáček;
161*eeb7e5b3SAdam Hornáček; All Recipient's rights under this Agreement shall terminate if it fails to
162*eeb7e5b3SAdam Hornáček; comply with any of the material terms or conditions of this Agreement and
163*eeb7e5b3SAdam Hornáček; does not cure such failure in a reasonable period of time after becoming
164*eeb7e5b3SAdam Hornáček; aware of such noncompliance. If all Recipient's rights under this Agreement
165*eeb7e5b3SAdam Hornáček; terminate, Recipient agrees to cease use and distribution of the Program as
166*eeb7e5b3SAdam Hornáček; soon as reasonably practicable. However, Recipient's obligations under this
167*eeb7e5b3SAdam Hornáček; Agreement and any licenses granted by Recipient relating to the Program
168*eeb7e5b3SAdam Hornáček; shall continue and survive.
169*eeb7e5b3SAdam Hornáček;
170*eeb7e5b3SAdam Hornáček; Everyone is permitted to copy and distribute copies of this Agreement, but
171*eeb7e5b3SAdam Hornáček; in order to avoid inconsistency the Agreement is copyrighted and may only be
172*eeb7e5b3SAdam Hornáček; modified in the following manner. The Agreement Steward reserves the right
173*eeb7e5b3SAdam Hornáček; to publish new versions (including revisions) of this Agreement from time to
174*eeb7e5b3SAdam Hornáček; time. No one other than the Agreement Steward has the right to modify this
175*eeb7e5b3SAdam Hornáček; Agreement. The Eclipse Foundation is the initial Agreement Steward. The
176*eeb7e5b3SAdam Hornáček; Eclipse Foundation may assign the responsibility to serve as the Agreement
177*eeb7e5b3SAdam Hornáček; Steward to a suitable separate entity. Each new version of the Agreement
178*eeb7e5b3SAdam Hornáček; will be given a distinguishing version number. The Program (including
179*eeb7e5b3SAdam Hornáček; Contributions) may always be distributed subject to the version of the
180*eeb7e5b3SAdam Hornáček; Agreement under which it was received. In addition, after a new version of
181*eeb7e5b3SAdam Hornáček; the Agreement is published, Contributor may elect to distribute the Program
182*eeb7e5b3SAdam Hornáček; (including its Contributions) under the new version. Except as expressly
183*eeb7e5b3SAdam Hornáček; stated in Sections 2(a) and 2(b) above, Recipient receives no rights or
184*eeb7e5b3SAdam Hornáček; licenses to the intellectual property of any Contributor under this
185*eeb7e5b3SAdam Hornáček; Agreement, whether expressly, by implication, estoppel or otherwise. All
186*eeb7e5b3SAdam Hornáček; rights in the Program not expressly granted under this Agreement are
187*eeb7e5b3SAdam Hornáček; reserved.
188*eeb7e5b3SAdam Hornáček;
189*eeb7e5b3SAdam Hornáček; This Agreement is governed by the laws of the State of New York and the
190*eeb7e5b3SAdam Hornáček; intellectual property laws of the United States of America. No party to this
191*eeb7e5b3SAdam Hornáček; Agreement will bring a legal action under this Agreement more than one year
192*eeb7e5b3SAdam Hornáček; after the cause of action arose. Each party waives its rights to a jury
193*eeb7e5b3SAdam Hornáček; trial in any resulting litigation.
194*eeb7e5b3SAdam Hornáček
195*eeb7e5b3SAdam Hornáček(ns koans.23-meta
196*eeb7e5b3SAdam Hornáček  (:require [koan-engine.core :refer :all]))
197*eeb7e5b3SAdam Hornáček
198*eeb7e5b3SAdam Hornáček(def giants
199*eeb7e5b3SAdam Hornáček  (with-meta 'Giants
200*eeb7e5b3SAdam Hornáček    {:league "National League"}))
201*eeb7e5b3SAdam Hornáček
202*eeb7e5b3SAdam Hornáček(meditations
203*eeb7e5b3SAdam Hornáček  "Some objects can be tagged using the with-meta function"
204*eeb7e5b3SAdam Hornáček  (= __ (meta giants))
205*eeb7e5b3SAdam Hornáček
206*eeb7e5b3SAdam Hornáček  "Or more succinctly with a reader macro"
207*eeb7e5b3SAdam Hornáček  (= __ (meta '^{:division "West"} Giants))
208*eeb7e5b3SAdam Hornáček
209*eeb7e5b3SAdam Hornáček  "While others can't"
210*eeb7e5b3SAdam Hornáček  (= __ (try
211*eeb7e5b3SAdam Hornáček          (with-meta
212*eeb7e5b3SAdam Hornáček            2
213*eeb7e5b3SAdam Hornáček            {:prime true})
214*eeb7e5b3SAdam Hornáček          (catch ClassCastException e
215*eeb7e5b3SAdam Hornáček            "This doesn't implement the IObj interface")))
216*eeb7e5b3SAdam Hornáček
217*eeb7e5b3SAdam Hornáček  "Notice when metadata carries over"
218*eeb7e5b3SAdam Hornáček  (= __ (meta (merge '^{:foo :bar} {:a 1 :b 2}
219*eeb7e5b3SAdam Hornáček                     {:b 3 :c 4})))
220*eeb7e5b3SAdam Hornáček
221*eeb7e5b3SAdam Hornáček  "And when it doesn't"
222*eeb7e5b3SAdam Hornáček  (= __ (meta (merge {:a 1 :b 2}
223*eeb7e5b3SAdam Hornáček                     '^{:foo :bar} {:b 3 :c 36rCRAZY})))
224*eeb7e5b3SAdam Hornáček
225*eeb7e5b3SAdam Hornáček  "Metadata can be used as a type hint to avoid reflection during runtime"
226*eeb7e5b3SAdam Hornáček  (= __ (#(.charAt ^String % 0) "Cast me"))
227*eeb7e5b3SAdam Hornáček
228*eeb7e5b3SAdam Hornáček  "You can directly update an object's metadata"
229*eeb7e5b3SAdam Hornáček  (= 0xFF (let [giants
230*eeb7e5b3SAdam Hornáček             (with-meta
231*eeb7e5b3SAdam Hornáček               'Giants
232*eeb7e5b3SAdam Hornáček               {:world-series-titles (atom 7)})]
233*eeb7e5b3SAdam Hornáček         (swap! (:world-series-titles (meta giants)) __)
234*eeb7e5b3SAdam Hornáček         @(:world-series-titles (meta giants))))
235*eeb7e5b3SAdam Hornáček
236*eeb7e5b3SAdam Hornáček  "You can also create a new object from another object with metadata"
237*eeb7e5b3SAdam Hornáček  (= {:league "National League" :park "AT&T Park"}
238*eeb7e5b3SAdam Hornáček     (meta (vary-meta giants
239*eeb7e5b3SAdam Hornáček                      assoc __ __)))
240*eeb7e5b3SAdam Hornáček
241*eeb7e5b3SAdam Hornáček  "But it won't affect behavior like equality"
242*eeb7e5b3SAdam Hornáček  (= __ (vary-meta giants dissoc :league))
243*eeb7e5b3SAdam Hornáček
244*eeb7e5b3SAdam Hornáček  "Or the object's printed representation"
245*eeb7e5b3SAdam Hornáček  (= __ (pr-str (vary-meta giants dissoc :league))))
246