Newbie Rewriting Trouble

20 views
Skip to first unread message

Hossein

unread,
Jan 31, 2012, 6:13:22 PM1/31/12
to kiama
Dear all,

In a Scala project which does already have kiama_2.9.0-1.1.0.jar in
its build path, can anyone explain the following console behaviour:

scala> import org.kiama.rewriting;
import org.kiama.rewriting

scala> val fail = strategyf (_ => None);
<console>:12: error: not found: value strategyf
val fail = strategyf (_ => None);
^

Is strategyf not in org.kiama.rewriting then? Or, is it that I needed
to do something more than simply adding the jar to the build path?

TIA,
--Hossein

Tony Sloane

unread,
Feb 1, 2012, 2:14:45 AM2/1/12
to ki...@googlegroups.com

org.kiama.rewriting is the package. You need to import things from the Rewriting object in that package. E.g.,

scala> import org.kiama.rewriting.Rewriter.strategyf
import org.kiama.rewriting.Rewriter.strategyf

scala> val fail = strategyf (_ => None)

fail: org.kiama.rewriting.Rewriter.Strategy = <function1>

You can do something like

import org.kiama.rewriting.Rewriter.{foo, bar, ble}

if you want to import more than one thing from that object,

or

import org.kiama.rewriting.Rewriter._

if you want to import them all.

I've updated the wiki page to make this clearer.

regards,
Tony

Seyed H. HAERI (Hossein)

unread,
Feb 1, 2012, 9:03:14 AM2/1/12
to ki...@googlegroups.com
Hi Tony,

> import org.kiama.rewriting.Rewriter._

Yup. This works now.

> I've updated the wiki page to make this clearer.

Great. :)

Thanks,
--Hossein

--------------------------------------------------------------------------------------------------------------

Seyed H. HAERI (Hossein)

Research Assistant
Institute for Software Systems (STS)
Technical University of Hamburg (TUHH)
Hamburg, Germany

ACCU - Professionalism in programming - http://www.accu.org/
--------------------------------------------------------------------------------------------------------------

Seyed H. HAERI (Hossein)

unread,
Feb 5, 2012, 8:21:35 AM2/5/12
to ki...@googlegroups.com
Tony,

>> I've updated the wiki page to make this clearer.

Just noticed a typo in this note:

import org.kiama.rewriting.Rewriting._

should have been:

import org.kiama.rewriting.Rewriter._

TTFN,

Tony Sloane

unread,
Feb 5, 2012, 8:38:58 AM2/5/12
to ki...@googlegroups.com
Thanks. Fixed.

cheers,
Tony

> --
> You received this message because you are subscribed to the Google Groups "kiama" group.
> To post to this group, send email to ki...@googlegroups.com.
> To unsubscribe from this group, send email to kiama+un...@googlegroups.com.
> For more options, visit this group at http://groups.google.com/group/kiama?hl=en.
>

Seyed H. HAERI (Hossein)

unread,
May 3, 2012, 11:39:52 AM5/3/12
to ki...@googlegroups.com
Hi again,

This time, I have a project that includes kiama_2.9.0-1.1.0.jar in its
build-path, and

scala> import org.kiama.rewriting.Rewriter._
<console>:7: error: object kiama is not a member of package org
import org.kiama.rewriting.Rewriter._

Looks to me like the Kiama stuff is somehow not visible to REPL. Any
idea how I can get that fixed? [Scala 2.9.1 Eclipse 3.7.1 Win7SP1]

TIA,
--Hossein

P.S. I guess part of me asking these very newbie questions
repetitively is for I've so far only been a casual Scala programmer
and have only very barely had the chance to experience Kaiam in
action. Please bear with me until I get my own grips with Scala and
Kiama.

Tony Sloane

unread,
May 3, 2012, 1:57:43 PM5/3/12
to ki...@googlegroups.com
Hi Hossein,

No problem with the question. The error indicates that Kiama is not on the classpath of the REPL.

How are you creating the REPL? If you were using the "console" command in sbt, then the classpath of the REPL would automatically include all of the dependent classes.

I don't use the Scala IDE for Eclipse, so I'm not sure how the equivalent of sbt's "console" command is achieved. However, it is done, I would have thought it would take into account your project's classpath settings, though.

Are you able to compile and run code in the Eclipse, but not in the REPL?

Can you get to *any* classes from your classpath via the REPL?

My guess is that the problem is not specific to Kiama, so you might be better off asking on the scala-ide list, since I'm not sure how many Scala IDE experts we have on this list.

regards,
Tony

Seyed H. HAERI (Hossein)

unread,
May 4, 2012, 5:38:25 AM5/4/12
to ki...@googlegroups.com
Hi Tony,

> I don't use the Scala IDE for Eclipse, so I'm not sure how the equivalent of sbt's "console" command is achieved. However, it is done, I would have thought it would take into account your project's classpath settings, though.

I don't use sbt. I have added the jar file to my project.

> Are you able to compile and run code in the Eclipse, but not in the REPL?

Nope.

> Can you get to *any* classes from your classpath via the REPL?

Well, I can import other packages, such as Scala's mutable map for
example. Yet, I'm not sure whether I fully understand your use of the
term "classpath" here. How can I acquire my REPL classpath?

> My guess is that the problem is not specific to Kiama, so you might be better off asking on the scala-ide list, since I'm not sure how many Scala IDE experts we have on this list.

OK, no problem. I'll fire off something to scala-ide too.

Thanks,
--Hossein

Tony Sloane

unread,
May 4, 2012, 5:51:58 AM5/4/12
to ki...@googlegroups.com
On 04/05/2012, at 11:38 AM, Seyed H. HAERI (Hossein) wrote:

> Hi Tony,
>
>> I don't use the Scala IDE for Eclipse, so I'm not sure how the equivalent of sbt's "console" command is achieved. However, it is done, I would have thought it would take into account your project's classpath settings, though.
>
> I don't use sbt. I have added the jar file to my project.
>

>> Are you able to compile and run code in the Eclipse, but not in the REPL?
>
> Nope.

Sorry, but do you mean that you can't compile and run in Eclipse? Or
that you can compile and run in Eclipse but not in the REPL?

If the former, then it would indicate that the libraries have not been
correctly added to the build path of the Eclipse project.

If the latter, then there must be something REPL-specific going on.

>> Can you get to *any* classes from your classpath via the REPL?
>
> Well, I can import other packages, such as Scala's mutable map for
> example. Yet, I'm not sure whether I fully understand your use of the
> term "classpath" here. How can I acquire my REPL classpath?

If you are in the REPL you can run the :cp command to add a directory
to the classpath. If you do it with no arguments, it will add the
current directory. More usefully, it will also print out the new
classpath so you can see what it is set to.

>> My guess is that the problem is not specific to Kiama, so you might be better off asking on the scala-ide list, since I'm not sure how many Scala IDE experts we have on this list.
>
> OK, no problem. I'll fire off something to scala-ide too.

regards,
Tony

Seyed H. HAERI (Hossein)

unread,
May 4, 2012, 6:23:13 AM5/4/12
to ki...@googlegroups.com
OK, I spotted the problem. My mistake, sorry... :( I was using the
source jar file rather kiama's one itself.
> --
> You received this message because you are subscribed to the Google Groups "kiama" group.
> To post to this group, send email to ki...@googlegroups.com.
> To unsubscribe from this group, send email to kiama+un...@googlegroups.com.
> For more options, visit this group at http://groups.google.com/group/kiama?hl=en.
>



--

Tony Sloane

unread,
May 4, 2012, 6:33:04 AM5/4/12
to ki...@googlegroups.com
Ok, no worries. Glad you got it working.

cheers,
Tony
Reply all
Reply to author
Forward
0 new messages