Comments (9)
I think the problem is that in Java, classes in the default package cannot be imported into another packaged class.
Since Scrap.fr
doesn't have a package element, it is compiled into default package which can be accessible only using reflection. :browse
uses reflection hence it is able to access the class and print the members while the import
in the generated Java source cannot access default package classes.
from frege-repl.
So are you saying that error comes from the Java compiler?
from frege-repl.
Most likely but it could also be Frege compiler. I am not sure even how
Frege compiler can import a class in the default package into a packaged
module. Even if it does that, I don't think it is possible with Java
compiler.
On Tuesday, October 28, 2014, Ingo Wechsung [email protected]
wrote:
So are you saying that error comes from the Java compiler?
—
Reply to this email directly or view it on GitHub
#10 (comment).
from frege-repl.
The compiler reads only the annotations on an import, and then rebuilds the symbol table based on the information (type FregePackage).
I guess this counts also as reflection.
A short test reveals that importing some class from the unnamed package is indeed impossible, the SDK javac does not even allow an unqualified name after import:
ingo@ibinti:~/frege$ fregec -d /tmp/x /tmp/B.fr /tmp/A.fr # A imports B
calling: javac -cp build:/tmp -d /tmp -sourcepath . -encoding UTF-8 /tmp/x/B.java
calling: javac -cp build:/tmp -d /tmp -sourcepath . -encoding UTF-8 /tmp/x/A.java
/tmp/x/A.java:16: error: '.' expected
import B;
^
/tmp/x/A.java:16: error: ';' expected
import B;
^
/tmp/x/A.java:17: error: class, interface, or enum expected
import frege.control.Category;
^
3 errors
E /tmp/A.fr:5: java compiler errors are most likely caused by erronous
native definitions
runtime 6.443 wallclock seconds.
However, we could nevertheless just use B from A. I confirmed this by removing the import B from A.java and recompiling.
So, it turns out the code generator must not generate import statements for simple packages!
However, we can use such classes only from classes in other unnamed packages.
So, as I see it, we need following fixes:
- code generation must not generate imports of classes from unnamed packages
- a frege import of a simple name in a module with a non-simple name must get flagged (I hate to do this, because it makes absolutely no sense! But, no choice.)
- the repl session package must itself be simple (i.e. Console, instead of frege.repl.Console)
If you agree with me, I shall prepare the first two fixes relative to 3.21.500.
I consider this crucial, for the simple reason that it is most likely that beginners begin with something like
module Test where
and then get disappointed when they try that in the REPL and get errors without them having done anything wrong.
from frege-repl.
Thanks Ingo! That clears up a lot of things.
I also agree with those fixes you proposed. I will make the necessary
changes in the REPL later today.
On Tuesday, October 28, 2014, Ingo Wechsung [email protected]
wrote:
The compiler reads only the annotations on an import, and then rebuilds
the symbol table based on the information (type FregePackage).
I guess this counts also as reflection.A short test reveals that importing some class from the unnamed package is
indeed impossible, the SDK javac does not even allow an unqualified name
after import:ingo@ibinti:~/frege$ fregec -d /tmp/x /tmp/B.fr /tmp/A.fr # A imports B
calling: javac -cp build:/tmp -d /tmp -sourcepath . -encoding UTF-8 /tmp/x/B.java
calling: javac -cp build:/tmp -d /tmp -sourcepath . -encoding UTF-8 /tmp/x/A.java
/tmp/x/A.java:16: error: '.' expected
import B;
^
/tmp/x/A.java:16: error: ';' expected
import B;
^
/tmp/x/A.java:17: error: class, interface, or enum expected
import frege.control.Category;
^
3 errors
E /tmp/A.fr:5: java compiler errors are most likely caused by erronous
native definitions
runtime 6.443 wallclock seconds.However, we could nevertheless just use B from A. I confirmed this by
removing the import B from A.java and recompiling.So, it turns out the code generator must not generate import statements
for simple packages!However, we can use such classes only from classes in other unnamed
packages.So, as I see it, we need following fixes:
- code generation must not generate imports of classes from unnamed
packages- a frege import of a simple name in a module with a non-simple name
must get flagged (I hate to do this, because it makes absolutely no sense!
But, no choice.)- the repl session package must itself be simple (i.e. Console,
instead of frege.repl.Console)If you agree with me, I shall prepare the first two fixes relative to
3.21.500.I consider this crucial, for the simple reason that it is most likely that
beginners begin with something likemodule Test where
and then get disappointed when they try that in the REPL and get errors
without them having done anything wrong.—
Reply to this email directly or view it on GitHub
#10 (comment).
from frege-repl.
Fine then. I have created an issue accordingly for the frege project .
Note I will work on the release21 branch, which corresponds to the "FInal 21" release, so the fixes will be relative to 3.21.586 (not 500, as I said before).
Keep watching for commits to frege!
from frege-repl.
REPL session is now compiled into the default package. Both online and command line REPL are updated and are also upgraded to 3.21.586.
$ java -jar frege-repl-1.0.3-SNAPSHOT.jar
Welcome to Frege 3.21.586-g026e8d7 (Oracle Corporation Java HotSpot(TM) 64-Bit Server VM, 1.8.0_25)
frege> module Foo where { bar = "I am Bar!" }
Module Foo
frege> pure native bar Foo.bar :: String
native function bar :: String
frege> bar
I am Bar!
from frege-repl.
Should be fixed with commit 8b2dcd87b8dc41f1ef808eb83ffa8d23e0babf7a
Or does it?
from frege-repl.
Sorry, I am not sure how I missed your comment. Yes, this issue is fixed.
from frege-repl.
Related Issues (20)
- :t infixl crashes repl HOT 3
- First official release HOT 4
- Make ReplIO control the javaSource and helpGUI HOT 2
- REPL immediately exits HOT 2
- REPL does not read version from fregec.jar? HOT 2
- SNAPSHOT-1.2.0 commands not working HOT 3
- no warnings anymore in repl? HOT 1
- event expansion vs. tab expansion HOT 1
- update to new tag line HOT 1
- Remove the lib/frege*.jar from the repo HOT 1
- Support installation via Homebrew HOT 5
- generated fregei script does not work HOT 4
- Load files from directory HOT 1
- compatibility with newer versions of the compiler HOT 3
- Integration with Sbt Frege HOT 3
- frege-repl-1.4-SNAPSHOT.zip checksum changed HOT 7
- Integrate repl in frege.jar? HOT 1
- let gradle (or travis?) obtain recent frege.jar version from github HOT 2
- head of empty list returns a HOT 3
- Need to update gradle version to understand Modern Java versions (11+)
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from frege-repl.