Re: Packages

Artem Gr <[email protected]> Thu, 14 Jul 2005 22:40:28 +0400
Newsgroups gmane.comp.lang.nice.general
Message-ID <[email protected]>
This is a multi-part message in MIME format.
--------------070600080606010603020700
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 7bit

> I've been thinking it could be useful to have one file per package, 
> specifying package name, Nice package imports (and possibly exports), 
> and package version (plus possibly more). This would also integrate with 
> the package repository.

What about RFE 824450?
http://sourceforge.net/tracker/index.php?func=detail&aid=824450&group_id=12788&atid=362788
I think either one or another should be chosed and implemented...

I would go for 824450, especially if it will improve compilation speed 
(smaller namespace could mean less choices for typechecker).

Having requirements in the package descriptor is a good thing, but 
requirements might be automatically inserted into existing descriptor 
when jar file is generated by the nice compiler (And this might be 
better becouse some packages are referenced without being imported).

> By the way, if people have (even small) libraries that could be shared, 
> I would like to hear from them to test and lauch the package repository.

Here's one in the attachment.

--------------070600080606010603020700
Content-Type: text/plain;
 name="time.nice"
Content-Transfer-Encoding: 7bit
Content-Disposition: inline;
 filename="time.nice"

package ru.glim.util.time;

/**
 * Time cache and utility.<br>
 * Invocation of <code>System.currentTimeMillis()</code> is not as cheap as it is sometimes desired,
 * therefore when fine time granularity is not important, it may be beneficial to cache the current time.
 */

/**
 * Cached result of <code>Date#getTime</code>.
 */
public long currentMilliseconds() = CURRENT_MILLISECONDS;
  
/**
 * Number of days since "the epoch".<br>
 * This is simply a {@link #currentMilliseconds} divided by <code>86400 000</code>.
 */
public int currentDays() = CURRENT_DAYS;
  
/**
 * Cached current time in a standard Java Date object.
 */
public java.util.Date currentDate() = CURRENT_DATE;
  
/**
 * Cache current time.<br>
 * This method must be frequently invoked for the time caching to function.<br>
 * For example, this method could be invoked for each request before processing it,
 * or when the time is going to be noted for performance measurements.<br>
 */
public void updateTime(){
  let cd = new java.util.Date();
  CURRENT_DATE = cd;
  long ct = cd.getTime();
  CURRENT_MILLISECONDS = ct;
  ct /= 86400000L;
  CURRENT_DAYS = int( ct );
}

void _testTimeCache(){
  let wasDate = currentDate();
  let wasTime = currentMilliseconds();
  Thread.sleep( 50 );
  !assert equals( wasTime, currentMilliseconds() );
  updateTime();
  !assert ! equals( wasDate, currentDate() );
  !assert ! equals( wasTime, currentMilliseconds() );
  !assert equals( currentDate(), currentDate() );
  !assert equals( currentMilliseconds(), currentMilliseconds() );
}

private var java.util.Date CURRENT_DATE = new Date();
private var long CURRENT_MILLISECONDS = System.currentTimeMillis();
private var int CURRENT_DAYS = int( System.currentTimeMillis() / 86400000L );

--------------070600080606010603020700--


-------------------------------------------------------
SF.Net email is sponsored by: Discover Easy Linux Migration Strategies
from IBM. Find simple to follow Roadmaps, straightforward articles,
informative Webcasts and more! Get everything you need to get up to
speed, fast. http://ads.osdn.com/?ad_id=7477&alloc_id=16492&op=click