[Pharo-dev] Having comments for pragma?
jan.vrany at fit.cvut.cz
Sat Jun 25 05:52:12 EDT 2016
> In Java you *cannot* annotate any language element. You can annotate
> class, methods, instance variables, method arguments and temporaries
> and packages.
> Then when I take an annotation, for example an hibernate annotation:
> @Table(name = "EMPLOYEE")
> In the case of Hibernate, these annotation are for a class and they
> are used at *runtime* to bind the class instances with database
> entries (elements of this class are stored in the table EMPLOYEE).
> Now I've never seen anyone doing that, but as you can access the
> annotation at runtime, and you can extract from the annotation its
> name and its parameters (for example you could extract "Table" and
> "name -> EMPLOYEE". Then, using the Java reflective features, you can
> do something like:
> method = obj.getClass().getMethod(methodName, param1.class,
> param2.class, ..);
> method.invoke(obj, arg1, arg2,...);
> And this way you execute a method named "Table", "name" or "EMPLOYEE"
> with the parameter you want, as you could execute a method from any
> string matching a method name. We have the same primitive in Pharo on
> I would not say that pragmas are more powerful in Java. Can you give
> an example of something you can do with the Java annotation that you
> can't do with Pharo pragmas ?
Out of a curiosity, how can I annotate class, instance variable,
method argument or temporary, or package.
How can I annotate the pragma definition itself? How can I retrieve
annotations of a pragma definition?
I mean, I understand that you can *achieve* same effect, but you *can*
achieve it as well with no pragma support at all.
> In Slang we use pragma to annotate argument and temporary variables
> and it works just fine. When you describe in Pharo classes and
> instance variables using Magritte you can do the same thing as just
> annotating them.
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Pharo-dev